diff options
author | Sascha Montellese <sascha.montellese@gmail.com> | 2013-04-01 13:43:30 -0700 |
---|---|---|
committer | Sascha Montellese <sascha.montellese@gmail.com> | 2013-04-01 13:43:30 -0700 |
commit | cdd62b918dc3ff79fa5ffc9fea1b54995d3e3a2b (patch) | |
tree | a01d395492b2fc6947626a0fcd2847c5445df711 | |
parent | a58502e6b05cfe6f7c8e04372035cb5649b55c57 (diff) | |
parent | 30c8d292e63a54ce61492b59163ecbf17fc3c448 (diff) |
Merge pull request #2445 from Montellese/settings_cleanup_3
settings cleanup (CSkinSettings, CMediaSourceSettings, CMediaSettings and CViewStateSettings)
89 files changed, 2724 insertions, 1668 deletions
diff --git a/XBMC-ATV2.xcodeproj/project.pbxproj b/XBMC-ATV2.xcodeproj/project.pbxproj index 35ec3bdc91..5e15527ebd 100644 --- a/XBMC-ATV2.xcodeproj/project.pbxproj +++ b/XBMC-ATV2.xcodeproj/project.pbxproj @@ -137,6 +137,10 @@ DF64FE6F16C07B2C00D028FB /* ViewDatabase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF64FE6916C07B2C00D028FB /* ViewDatabase.cpp */; }; DF830D4815BB2CFC00602BE6 /* GUIKeyboardFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF830D4515BB2CFC00602BE6 /* GUIKeyboardFactory.cpp */; }; DF830D4B15BB2D2300602BE6 /* GUIDialogKeyboardGeneric.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF830D4915BB2D2300602BE6 /* GUIDialogKeyboardGeneric.cpp */; }; + DF8990041709B95B00B35C21 /* MediaSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF898FFE1709B95B00B35C21 /* MediaSettings.cpp */; }; + DF8990051709B95B00B35C21 /* MediaSourceSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF8990001709B95B00B35C21 /* MediaSourceSettings.cpp */; }; + DF8990061709B95B00B35C21 /* SkinSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF8990021709B95B00B35C21 /* SkinSettings.cpp */; }; + DF8990091709B97800B35C21 /* ViewStateSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF8990071709B97800B35C21 /* ViewStateSettings.cpp */; }; DF91D899161B759B004E6637 /* AddonsOperations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF91D897161B759B004E6637 /* AddonsOperations.cpp */; }; DF93D7701444B09C007C6459 /* AFPFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF93D7381444B09C007C6459 /* AFPFile.cpp */; }; DF93D7731444B09C007C6459 /* CDDAFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF93D73E1444B09C007C6459 /* CDDAFile.cpp */; }; @@ -1345,6 +1349,16 @@ DF830D4615BB2CFC00602BE6 /* GUIKeyboardFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIKeyboardFactory.h; sourceTree = "<group>"; }; DF830D4915BB2D2300602BE6 /* GUIDialogKeyboardGeneric.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GUIDialogKeyboardGeneric.cpp; sourceTree = "<group>"; }; DF830D4A15BB2D2300602BE6 /* GUIDialogKeyboardGeneric.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIDialogKeyboardGeneric.h; sourceTree = "<group>"; }; + DF898FFC1709B95B00B35C21 /* ISettingsHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISettingsHandler.h; sourceTree = "<group>"; }; + DF898FFD1709B95B00B35C21 /* ISubSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISubSettings.h; sourceTree = "<group>"; }; + DF898FFE1709B95B00B35C21 /* MediaSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaSettings.cpp; sourceTree = "<group>"; }; + DF898FFF1709B95B00B35C21 /* MediaSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSettings.h; sourceTree = "<group>"; }; + DF8990001709B95B00B35C21 /* MediaSourceSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaSourceSettings.cpp; sourceTree = "<group>"; }; + DF8990011709B95B00B35C21 /* MediaSourceSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSourceSettings.h; sourceTree = "<group>"; }; + DF8990021709B95B00B35C21 /* SkinSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SkinSettings.cpp; sourceTree = "<group>"; }; + DF8990031709B95B00B35C21 /* SkinSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SkinSettings.h; sourceTree = "<group>"; }; + DF8990071709B97800B35C21 /* ViewStateSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ViewStateSettings.cpp; sourceTree = "<group>"; }; + DF8990081709B97800B35C21 /* ViewStateSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewStateSettings.h; sourceTree = "<group>"; }; DF91D897161B759B004E6637 /* AddonsOperations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AddonsOperations.cpp; sourceTree = "<group>"; }; DF91D898161B759B004E6637 /* AddonsOperations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AddonsOperations.h; sourceTree = "<group>"; }; DF93D7381444B09C007C6459 /* AFPFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AFPFile.cpp; sourceTree = "<group>"; }; @@ -3589,6 +3603,8 @@ DF64FE6916C07B2C00D028FB /* ViewDatabase.cpp */, DF64FE6A16C07B2C00D028FB /* ViewDatabase.h */, DF64FE6B16C07B2C00D028FB /* ViewState.h */, + DF8990071709B97800B35C21 /* ViewStateSettings.cpp */, + DF8990081709B97800B35C21 /* ViewStateSettings.h */, ); path = view; sourceTree = "<group>"; @@ -5653,10 +5669,18 @@ F56C76D4131EC153000AD0F6 /* AdvancedSettings.h */, F56C76D1131EC153000AD0F6 /* GUISettings.cpp */, F56C76D2131EC153000AD0F6 /* GUISettings.h */, + DF898FFC1709B95B00B35C21 /* ISettingsHandler.h */, + DF898FFD1709B95B00B35C21 /* ISubSettings.h */, + DF898FFE1709B95B00B35C21 /* MediaSettings.cpp */, + DF898FFF1709B95B00B35C21 /* MediaSettings.h */, + DF8990001709B95B00B35C21 /* MediaSourceSettings.cpp */, + DF8990011709B95B00B35C21 /* MediaSourceSettings.h */, F56C76DD131EC153000AD0F6 /* Profile.cpp */, F56C76DE131EC153000AD0F6 /* Profile.h */, F56C76DF131EC153000AD0F6 /* Settings.cpp */, F56C76E0131EC153000AD0F6 /* Settings.h */, + DF8990021709B95B00B35C21 /* SkinSettings.cpp */, + DF8990031709B95B00B35C21 /* SkinSettings.h */, F56C76E3131EC153000AD0F6 /* VideoSettings.cpp */, F56C76E4131EC153000AD0F6 /* VideoSettings.h */, ); @@ -7669,6 +7693,10 @@ F563532416E5446C00D21BAD /* GUIWindowTestPattern.cpp in Sources */, F563532716E5447C00D21BAD /* AppParamParser.cpp in Sources */, DFAF6A6216EBAED000D6AE12 /* RssManager.cpp in Sources */, + DF8990041709B95B00B35C21 /* MediaSettings.cpp in Sources */, + DF8990051709B95B00B35C21 /* MediaSourceSettings.cpp in Sources */, + DF8990061709B95B00B35C21 /* SkinSettings.cpp in Sources */, + DF8990091709B97800B35C21 /* ViewStateSettings.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/XBMC-IOS.xcodeproj/project.pbxproj b/XBMC-IOS.xcodeproj/project.pbxproj index 4e4c9920fc..79c8fe0051 100644 --- a/XBMC-IOS.xcodeproj/project.pbxproj +++ b/XBMC-IOS.xcodeproj/project.pbxproj @@ -143,6 +143,10 @@ DF64FE5916C07AF700D028FB /* ViewDatabase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF64FE5316C07AF700D028FB /* ViewDatabase.cpp */; }; DF830C9515BB20FC00602BE6 /* GUIDialogKeyboardGeneric.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF830C9315BB20FC00602BE6 /* GUIDialogKeyboardGeneric.cpp */; }; DF830C9E15BB215500602BE6 /* GUIKeyboardFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF830C9C15BB215500602BE6 /* GUIKeyboardFactory.cpp */; }; + DF898FC21709B8E600B35C21 /* MediaSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF898FBC1709B8E600B35C21 /* MediaSettings.cpp */; }; + DF898FC31709B8E600B35C21 /* MediaSourceSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF898FBE1709B8E600B35C21 /* MediaSourceSettings.cpp */; }; + DF898FC41709B8E600B35C21 /* SkinSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF898FC01709B8E600B35C21 /* SkinSettings.cpp */; }; + DF898FC71709B90400B35C21 /* ViewStateSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF898FC51709B90400B35C21 /* ViewStateSettings.cpp */; }; DF91D88A161B7581004E6637 /* AddonsOperations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF91D888161B7581004E6637 /* AddonsOperations.cpp */; }; DF93D7CF1444B105007C6459 /* AFPFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF93D7971444B105007C6459 /* AFPFile.cpp */; }; DF93D7D21444B105007C6459 /* CDDAFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF93D79D1444B105007C6459 /* CDDAFile.cpp */; }; @@ -1366,6 +1370,16 @@ DF830C9415BB20FC00602BE6 /* GUIDialogKeyboardGeneric.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIDialogKeyboardGeneric.h; sourceTree = "<group>"; }; DF830C9C15BB215500602BE6 /* GUIKeyboardFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GUIKeyboardFactory.cpp; sourceTree = "<group>"; }; DF830C9D15BB215500602BE6 /* GUIKeyboardFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIKeyboardFactory.h; sourceTree = "<group>"; }; + DF898FBA1709B8E600B35C21 /* ISettingsHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISettingsHandler.h; sourceTree = "<group>"; }; + DF898FBB1709B8E600B35C21 /* ISubSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISubSettings.h; sourceTree = "<group>"; }; + DF898FBC1709B8E600B35C21 /* MediaSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaSettings.cpp; sourceTree = "<group>"; }; + DF898FBD1709B8E600B35C21 /* MediaSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSettings.h; sourceTree = "<group>"; }; + DF898FBE1709B8E600B35C21 /* MediaSourceSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaSourceSettings.cpp; sourceTree = "<group>"; }; + DF898FBF1709B8E600B35C21 /* MediaSourceSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSourceSettings.h; sourceTree = "<group>"; }; + DF898FC01709B8E600B35C21 /* SkinSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SkinSettings.cpp; sourceTree = "<group>"; }; + DF898FC11709B8E600B35C21 /* SkinSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SkinSettings.h; sourceTree = "<group>"; }; + DF898FC51709B90400B35C21 /* ViewStateSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ViewStateSettings.cpp; sourceTree = "<group>"; }; + DF898FC61709B90400B35C21 /* ViewStateSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewStateSettings.h; sourceTree = "<group>"; }; DF91D888161B7581004E6637 /* AddonsOperations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AddonsOperations.cpp; sourceTree = "<group>"; }; DF91D889161B7581004E6637 /* AddonsOperations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AddonsOperations.h; sourceTree = "<group>"; }; DF93D7971444B105007C6459 /* AFPFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AFPFile.cpp; sourceTree = "<group>"; }; @@ -3637,6 +3651,8 @@ DF64FE5316C07AF700D028FB /* ViewDatabase.cpp */, DF64FE5416C07AF700D028FB /* ViewDatabase.h */, DF64FE5516C07AF700D028FB /* ViewState.h */, + DF898FC51709B90400B35C21 /* ViewStateSettings.cpp */, + DF898FC61709B90400B35C21 /* ViewStateSettings.h */, ); path = view; sourceTree = "<group>"; @@ -6064,10 +6080,18 @@ F56C86BF131F42EB000AD0F6 /* AdvancedSettings.h */, F56C86BC131F42EB000AD0F6 /* GUISettings.cpp */, F56C86BD131F42EB000AD0F6 /* GUISettings.h */, + DF898FBA1709B8E600B35C21 /* ISettingsHandler.h */, + DF898FBB1709B8E600B35C21 /* ISubSettings.h */, + DF898FBC1709B8E600B35C21 /* MediaSettings.cpp */, + DF898FBD1709B8E600B35C21 /* MediaSettings.h */, + DF898FBE1709B8E600B35C21 /* MediaSourceSettings.cpp */, + DF898FBF1709B8E600B35C21 /* MediaSourceSettings.h */, F56C86C8131F42EB000AD0F6 /* Profile.cpp */, F56C86C9131F42EB000AD0F6 /* Profile.h */, F56C86CA131F42EB000AD0F6 /* Settings.cpp */, F56C86CB131F42EB000AD0F6 /* Settings.h */, + DF898FC01709B8E600B35C21 /* SkinSettings.cpp */, + DF898FC11709B8E600B35C21 /* SkinSettings.h */, F56C86CE131F42EB000AD0F6 /* VideoSettings.cpp */, F56C86CF131F42EB000AD0F6 /* VideoSettings.h */, ); @@ -7740,6 +7764,10 @@ 1D04C23B16E67BA20001BA1E /* GenericTouchActionHandler.cpp in Sources */, 1D04C24116E67BA20001BA1E /* ITouchInputHandling.cpp in Sources */, DFAF6A6D16EBAF4800D6AE12 /* RssManager.cpp in Sources */, + DF898FC21709B8E600B35C21 /* MediaSettings.cpp in Sources */, + DF898FC31709B8E600B35C21 /* MediaSourceSettings.cpp in Sources */, + DF898FC41709B8E600B35C21 /* SkinSettings.cpp in Sources */, + DF898FC71709B90400B35C21 /* ViewStateSettings.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/XBMC.xcodeproj/project.pbxproj b/XBMC.xcodeproj/project.pbxproj index 4d50a3157b..cf937da9d7 100644 --- a/XBMC.xcodeproj/project.pbxproj +++ b/XBMC.xcodeproj/project.pbxproj @@ -404,6 +404,10 @@ DF673AA51443819600A5A509 /* AddonManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 18B49FF41152BFA5001AF8A6 /* AddonManager.cpp */; }; DF830D0C15BB260C00602BE6 /* GUIDialogKeyboardGeneric.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF830D0A15BB260C00602BE6 /* GUIDialogKeyboardGeneric.cpp */; }; DF830D1215BB262700602BE6 /* GUIKeyboardFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF830D0F15BB262700602BE6 /* GUIKeyboardFactory.cpp */; }; + DF89901C1709BB2D00B35C21 /* MediaSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF8990161709BB2D00B35C21 /* MediaSettings.cpp */; }; + DF89901D1709BB2D00B35C21 /* MediaSourceSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF8990181709BB2D00B35C21 /* MediaSourceSettings.cpp */; }; + DF89901E1709BB2D00B35C21 /* SkinSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF89901A1709BB2D00B35C21 /* SkinSettings.cpp */; }; + DF8990211709BB5400B35C21 /* ViewStateSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF89901F1709BB5400B35C21 /* ViewStateSettings.cpp */; }; DF93D65D1444A7A3007C6459 /* SlingboxDirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF93D65C1444A7A3007C6459 /* SlingboxDirectory.cpp */; }; DF93D6991444A8B1007C6459 /* AFPFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF93D6631444A8B0007C6459 /* AFPFile.cpp */; }; DF93D69A1444A8B1007C6459 /* DirectoryCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF93D6651444A8B0007C6459 /* DirectoryCache.cpp */; }; @@ -1930,6 +1934,16 @@ DF830D0E15BB262700602BE6 /* GUIKeyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIKeyboard.h; sourceTree = "<group>"; }; DF830D0F15BB262700602BE6 /* GUIKeyboardFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GUIKeyboardFactory.cpp; sourceTree = "<group>"; }; DF830D1015BB262700602BE6 /* GUIKeyboardFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIKeyboardFactory.h; sourceTree = "<group>"; }; + DF8990141709BB2D00B35C21 /* ISettingsHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISettingsHandler.h; sourceTree = "<group>"; }; + DF8990151709BB2D00B35C21 /* ISubSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISubSettings.h; sourceTree = "<group>"; }; + DF8990161709BB2D00B35C21 /* MediaSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaSettings.cpp; sourceTree = "<group>"; }; + DF8990171709BB2D00B35C21 /* MediaSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSettings.h; sourceTree = "<group>"; }; + DF8990181709BB2D00B35C21 /* MediaSourceSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaSourceSettings.cpp; sourceTree = "<group>"; }; + DF8990191709BB2D00B35C21 /* MediaSourceSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSourceSettings.h; sourceTree = "<group>"; }; + DF89901A1709BB2D00B35C21 /* SkinSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SkinSettings.cpp; sourceTree = "<group>"; }; + DF89901B1709BB2D00B35C21 /* SkinSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SkinSettings.h; sourceTree = "<group>"; }; + DF89901F1709BB5400B35C21 /* ViewStateSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ViewStateSettings.cpp; sourceTree = "<group>"; }; + DF8990201709BB5400B35C21 /* ViewStateSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewStateSettings.h; sourceTree = "<group>"; }; DF93D65B1444A7A3007C6459 /* SlingboxDirectory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlingboxDirectory.h; sourceTree = "<group>"; }; DF93D65C1444A7A3007C6459 /* SlingboxDirectory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SlingboxDirectory.cpp; sourceTree = "<group>"; }; DF93D6631444A8B0007C6459 /* AFPFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AFPFile.cpp; sourceTree = "<group>"; }; @@ -4594,6 +4608,8 @@ DF64FE3A16C07AAA00D028FB /* ViewDatabase.cpp */, DF64FE3B16C07AAA00D028FB /* ViewDatabase.h */, DF64FE3C16C07AAA00D028FB /* ViewState.h */, + DF89901F1709BB5400B35C21 /* ViewStateSettings.cpp */, + DF8990201709BB5400B35C21 /* ViewStateSettings.h */, ); path = view; sourceTree = "<group>"; @@ -6087,10 +6103,18 @@ 18B7C3A712942132009E7A26 /* AdvancedSettings.h */, 18B7C8C212942451009E7A26 /* GUISettings.cpp */, 18B7C8C312942451009E7A26 /* GUISettings.h */, + DF8990141709BB2D00B35C21 /* ISettingsHandler.h */, + DF8990151709BB2D00B35C21 /* ISubSettings.h */, + DF8990161709BB2D00B35C21 /* MediaSettings.cpp */, + DF8990171709BB2D00B35C21 /* MediaSettings.h */, + DF8990181709BB2D00B35C21 /* MediaSourceSettings.cpp */, + DF8990191709BB2D00B35C21 /* MediaSourceSettings.h */, E38E1DF10D25F9FD00618676 /* Profile.cpp */, E38E1DF20D25F9FD00618676 /* Profile.h */, 18B7C38E129420E5009E7A26 /* Settings.cpp */, 18B7C38F129420E5009E7A26 /* Settings.h */, + DF89901A1709BB2D00B35C21 /* SkinSettings.cpp */, + DF89901B1709BB2D00B35C21 /* SkinSettings.h */, E38E1E010D25F9FD00618676 /* VideoSettings.cpp */, E38E1E020D25F9FD00618676 /* VideoSettings.h */, ); @@ -7740,6 +7764,10 @@ F56352C816E5436900D21BAD /* AppParamParser.cpp in Sources */, F56353BF16E9BB3500D21BAD /* BitstreamConverter.cpp in Sources */, DFAF6A4F16EBAE3800D6AE12 /* RssManager.cpp in Sources */, + DF89901C1709BB2D00B35C21 /* MediaSettings.cpp in Sources */, + DF89901D1709BB2D00B35C21 /* MediaSourceSettings.cpp in Sources */, + DF89901E1709BB2D00B35C21 /* SkinSettings.cpp in Sources */, + DF8990211709BB5400B35C21 /* ViewStateSettings.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/project/VS2010Express/XBMC.vcxproj b/project/VS2010Express/XBMC.vcxproj index ba3d8c25cd..0493f5bdb9 100644 --- a/project/VS2010Express/XBMC.vcxproj +++ b/project/VS2010Express/XBMC.vcxproj @@ -946,8 +946,11 @@ <ClCompile Include="..\..\xbmc\settings\dialogs\GUIDialogProfileSettings.cpp" /> <ClCompile Include="..\..\xbmc\settings\dialogs\GUIDialogSettings.cpp" /> <ClCompile Include="..\..\xbmc\settings\GUISettings.cpp" /> + <ClCompile Include="..\..\xbmc\settings\MediaSettings.cpp" /> + <ClCompile Include="..\..\xbmc\settings\MediaSourceSettings.cpp" /> <ClCompile Include="..\..\xbmc\settings\Profile.cpp" /> <ClCompile Include="..\..\xbmc\settings\Settings.cpp" /> + <ClCompile Include="..\..\xbmc\settings\SkinSettings.cpp" /> <ClCompile Include="..\..\xbmc\settings\VideoSettings.cpp" /> <ClCompile Include="..\..\xbmc\settings\windows\GUISettingControls.cpp" /> <ClCompile Include="..\..\xbmc\settings\windows\GUIWindowSettings.cpp" /> @@ -1093,6 +1096,11 @@ <ClInclude Include="..\..\xbmc\settings\dialogs\GUIDialogLockSettings.h" /> <ClInclude Include="..\..\xbmc\settings\dialogs\GUIDialogProfileSettings.h" /> <ClInclude Include="..\..\xbmc\settings\dialogs\GUIDialogSettings.h" /> + <ClInclude Include="..\..\xbmc\settings\ISettingsHandler.h" /> + <ClInclude Include="..\..\xbmc\settings\ISubSettings.h" /> + <ClInclude Include="..\..\xbmc\settings\MediaSettings.h" /> + <ClInclude Include="..\..\xbmc\settings\MediaSourceSettings.h" /> + <ClInclude Include="..\..\xbmc\settings\SkinSettings.h" /> <ClInclude Include="..\..\xbmc\settings\windows\GUISettingControls.h" /> <ClInclude Include="..\..\xbmc\settings\windows\GUIWindowSettings.h" /> <ClInclude Include="..\..\xbmc\settings\windows\GUIWindowSettingsCategory.h" /> @@ -1665,6 +1673,7 @@ <ClCompile Include="..\..\xbmc\view\GUIViewControl.cpp" /> <ClCompile Include="..\..\xbmc\view\GUIViewState.cpp" /> <ClCompile Include="..\..\xbmc\view\ViewDatabase.cpp" /> + <ClCompile Include="..\..\xbmc\view\ViewStateSettings.cpp" /> <ClCompile Include="..\..\xbmc\win32\pch.cpp"> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug (DirectX)|Win32'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug Testsuite|Win32'">Create</PrecompiledHeader> @@ -2495,6 +2504,7 @@ <ClInclude Include="..\..\xbmc\view\GUIViewState.h" /> <ClInclude Include="..\..\xbmc\view\ViewDatabase.h" /> <ClInclude Include="..\..\xbmc\view\ViewState.h" /> + <ClInclude Include="..\..\xbmc\view\ViewStateSettings.h" /> <ClInclude Include="..\..\xbmc\win32\pch.h" /> <ClInclude Include="..\..\xbmc\win32\PlatformDefs.h" /> <ClInclude Include="..\..\xbmc\XBDateTime.h" /> diff --git a/project/VS2010Express/XBMC.vcxproj.filters b/project/VS2010Express/XBMC.vcxproj.filters index 791c5182f7..e66cf60dc7 100644 --- a/project/VS2010Express/XBMC.vcxproj.filters +++ b/project/VS2010Express/XBMC.vcxproj.filters @@ -2973,6 +2973,18 @@ <ClCompile Include="..\..\xbmc\utils\RssManager.cpp"> <Filter>utils</Filter> </ClCompile> + <ClCompile Include="..\..\xbmc\settings\SkinSettings.cpp"> + <Filter>settings</Filter> + </ClCompile> + <ClCompile Include="..\..\xbmc\settings\MediaSourceSettings.cpp"> + <Filter>settings</Filter> + </ClCompile> + <ClCompile Include="..\..\xbmc\view\ViewStateSettings.cpp"> + <Filter>view</Filter> + </ClCompile> + <ClCompile Include="..\..\xbmc\settings\MediaSettings.cpp"> + <Filter>settings</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\..\xbmc\win32\pch.h"> @@ -5807,6 +5819,24 @@ <ClInclude Include="..\..\xbmc\utils\RssManager.h"> <Filter>utils</Filter> </ClInclude> + <ClInclude Include="..\..\xbmc\settings\ISettingsHandler.h"> + <Filter>settings</Filter> + </ClInclude> + <ClInclude Include="..\..\xbmc\settings\ISubSettings.h"> + <Filter>settings</Filter> + </ClInclude> + <ClInclude Include="..\..\xbmc\settings\SkinSettings.h"> + <Filter>settings</Filter> + </ClInclude> + <ClInclude Include="..\..\xbmc\settings\MediaSourceSettings.h"> + <Filter>settings</Filter> + </ClInclude> + <ClInclude Include="..\..\xbmc\view\ViewStateSettings.h"> + <Filter>view</Filter> + </ClInclude> + <ClInclude Include="..\..\xbmc\settings\MediaSettings.h"> + <Filter>settings</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ResourceCompile Include="..\..\xbmc\win32\XBMC_PC.rc"> diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp index 543867674f..ca88b34306 100644 --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp @@ -95,9 +95,14 @@ #include "powermanagement/DPMSSupport.h" #include "settings/Settings.h" #include "settings/AdvancedSettings.h" +#include "settings/MediaSettings.h" +#include "settings/MediaSourceSettings.h" +#include "settings/SkinSettings.h" #include "guilib/LocalizeStrings.h" #include "utils/CPUInfo.h" +#include "utils/RssManager.h" #include "utils/SeekHandler.h" +#include "view/ViewStateSettings.h" #include "input/KeyboardStat.h" #include "input/XBMC_vkeys.h" @@ -112,6 +117,7 @@ #endif #ifdef HAS_UPNP #include "network/upnp/UPnP.h" +#include "network/upnp/UPnPSettings.h" #include "filesystem/UPnPDirectory.h" #endif #if defined(_LINUX) && defined(HAS_FILESYSTEM_SMB) @@ -702,6 +708,18 @@ bool CApplication::Create() } CLog::Log(LOGNOTICE, "load settings..."); + g_settings.RegisterSettingsHandler(this); + g_settings.RegisterSettingsHandler(&g_advancedSettings); + g_settings.RegisterSettingsHandler(&CMediaSourceSettings::Get()); + g_settings.RegisterSettingsHandler(&CPlayerCoreFactory::Get()); + g_settings.RegisterSettingsHandler(&CRssManager::Get()); +#ifdef HAS_UPNP + g_settings.RegisterSettingsHandler(&CUPnPSettings::Get()); +#endif + + g_settings.RegisterSubSettings(&CMediaSettings::Get()); + g_settings.RegisterSubSettings(&CSkinSettings::Get()); + g_settings.RegisterSubSettings(&CViewStateSettings::Get()); g_guiSettings.Initialize(); // Initialize default Settings - don't move g_powerManager.SetDefaults(); @@ -1913,6 +1931,14 @@ void CApplication::ReloadSkin() } } +bool CApplication::OnSettingsSaving() const +{ + // Don't save settings when we're busy stopping the application. + // A lot of screens try to save settings on deinit and deinit is called + // for every screen when the application is stopping. + return !m_bStop; +} + bool CApplication::LoadSkin(const CStdString& skinID) { if (m_skinReloading) @@ -3485,6 +3511,19 @@ bool CApplication::Cleanup() g_settings.Clear(); g_guiSettings.Clear(); g_advancedSettings.Clear(); + + g_settings.UnregisterSubSettings(&CMediaSettings::Get()); + g_settings.UnregisterSubSettings(&CSkinSettings::Get()); + g_settings.UnregisterSubSettings(&CViewStateSettings::Get()); + + g_settings.UnregisterSettingsHandler(&g_advancedSettings); + g_settings.UnregisterSettingsHandler(&CMediaSourceSettings::Get()); + g_settings.UnregisterSettingsHandler(&CPlayerCoreFactory::Get()); + g_settings.UnregisterSettingsHandler(&CRssManager::Get()); +#ifdef HAS_UPNP + g_settings.UnregisterSettingsHandler(&CUPnPSettings::Get()); +#endif + g_settings.UnregisterSettingsHandler(this); #ifdef _LINUX CXHandle::DumpObjectTracker(); @@ -3789,7 +3828,7 @@ bool CApplication::PlayStack(const CFileItem& item, bool bRestart) CVideoDatabase dbs; if (dbs.Open()) { - dbs.GetVideoSettings(item.GetPath(), g_settings.m_currentVideoSettings); + dbs.GetVideoSettings(item.GetPath(), CMediaSettings::Get().GetCurrentVideoSettings()); haveTimes = dbs.GetStackTimes(item.GetPath(), times); dbs.Close(); } @@ -3872,7 +3911,7 @@ bool CApplication::PlayFile(const CFileItem& item, bool bRestart) OutputDebugString("new file set audiostream:0\n"); // Switch to default options - g_settings.m_currentVideoSettings = g_settings.m_defaultVideoSettings; + CMediaSettings::Get().GetCurrentVideoSettings() = CMediaSettings::Get().GetDefaultVideoSettings(); // see if we have saved options in the database SetPlaySpeed(1); @@ -3994,7 +4033,7 @@ bool CApplication::PlayFile(const CFileItem& item, bool bRestart) // open the d/b and retrieve the bookmarks for the current movie CVideoDatabase dbs; dbs.Open(); - dbs.GetVideoSettings(item.GetPath(), g_settings.m_currentVideoSettings); + dbs.GetVideoSettings(item.GetPath(), CMediaSettings::Get().GetCurrentVideoSettings()); if( item.m_lStartOffset == STARTOFFSET_RESUME ) { @@ -5363,13 +5402,13 @@ void CApplication::VolumeChanged() const int CApplication::GetSubtitleDelay() const { // converts subtitle delay to a percentage - return int(((float)(g_settings.m_currentVideoSettings.m_SubtitleDelay + g_advancedSettings.m_videoSubsDelayRange)) / (2 * g_advancedSettings.m_videoSubsDelayRange)*100.0f + 0.5f); + return int(((float)(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay + g_advancedSettings.m_videoSubsDelayRange)) / (2 * g_advancedSettings.m_videoSubsDelayRange)*100.0f + 0.5f); } int CApplication::GetAudioDelay() const { // converts audio delay to a percentage - return int(((float)(g_settings.m_currentVideoSettings.m_AudioDelay + g_advancedSettings.m_videoAudioDelayRange)) / (2 * g_advancedSettings.m_videoAudioDelayRange)*100.0f + 0.5f); + return int(((float)(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay + g_advancedSettings.m_videoAudioDelayRange)) / (2 * g_advancedSettings.m_videoAudioDelayRange)*100.0f + 0.5f); } void CApplication::SetPlaySpeed(int iSpeed) @@ -5772,11 +5811,11 @@ void CApplication::SaveCurrentFileSettings() if (m_itemCurrentFile->IsVideo() && !m_itemCurrentFile->IsPVRChannel()) { // save video settings - if (g_settings.m_currentVideoSettings != g_settings.m_defaultVideoSettings) + if (CMediaSettings::Get().GetCurrentVideoSettings() != CMediaSettings::Get().GetDefaultVideoSettings()) { CVideoDatabase dbs; dbs.Open(); - dbs.SetVideoSettings(m_itemCurrentFile->GetPath(), g_settings.m_currentVideoSettings); + dbs.SetVideoSettings(m_itemCurrentFile->GetPath(), CMediaSettings::Get().GetCurrentVideoSettings()); dbs.Close(); } } diff --git a/xbmc/Application.h b/xbmc/Application.h index aaa3c59a66..ef31d06d84 100644 --- a/xbmc/Application.h +++ b/xbmc/Application.h @@ -48,6 +48,7 @@ namespace MEDIA_DETECT #include "cores/IPlayerCallback.h" #include "cores/playercorefactory/PlayerCoreFactory.h" #include "PlayListPlayer.h" +#include "settings/ISettingsHandler.h" #if !defined(_WIN32) && defined(HAS_DVD_DRIVE) #include "storage/DetectDVDType.h" #endif @@ -105,7 +106,8 @@ protected: int m_iPlayList; }; -class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMsgTargetCallback +class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMsgTargetCallback, + public ISettingsHandler { public: @@ -367,6 +369,8 @@ public: CSplash* GetSplash() { return m_splash; } void SetRenderGUI(bool renderGUI); protected: + virtual bool OnSettingsSaving() const; + bool LoadSkin(const CStdString& skinID); void LoadSkin(const boost::shared_ptr<ADDON::CSkinInfo>& skin); diff --git a/xbmc/AutoSwitch.cpp b/xbmc/AutoSwitch.cpp index ab07066944..76eec917dc 100644 --- a/xbmc/AutoSwitch.cpp +++ b/xbmc/AutoSwitch.cpp @@ -24,6 +24,7 @@ #include "guilib/GUIWindowManager.h" #include "FileItem.h" #include "guilib/WindowIDs.h" +#include "view/ViewState.h" #define METHOD_BYFOLDERS 0 #define METHOD_BYFILES 1 diff --git a/xbmc/GUIInfoManager.cpp b/xbmc/GUIInfoManager.cpp index f709b6de65..3e1e8fda66 100644 --- a/xbmc/GUIInfoManager.cpp +++ b/xbmc/GUIInfoManager.cpp @@ -43,7 +43,9 @@ #include "windowing/WindowingFactory.h" #include "powermanagement/PowerManager.h" #include "settings/AdvancedSettings.h" +#include "settings/MediaSettings.h" #include "settings/Settings.h" +#include "settings/SkinSettings.h" #include "guilib/LocalizeStrings.h" #include "utils/CharsetConverter.h" #include "utils/CPUInfo.h" @@ -1017,12 +1019,12 @@ int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition) if (prop.name == "string") { if (prop.num_params() == 2) - return AddMultiInfo(GUIInfo(SKIN_STRING, g_settings.TranslateSkinString(prop.param(0)), ConditionalStringParameter(prop.param(1)))); + return AddMultiInfo(GUIInfo(SKIN_STRING, CSkinSettings::Get().TranslateString(prop.param(0)), ConditionalStringParameter(prop.param(1)))); else - return AddMultiInfo(GUIInfo(SKIN_STRING, g_settings.TranslateSkinString(prop.param(0)))); + return AddMultiInfo(GUIInfo(SKIN_STRING, CSkinSettings::Get().TranslateString(prop.param(0)))); } if (prop.name == "hassetting") - return AddMultiInfo(GUIInfo(SKIN_BOOL, g_settings.TranslateSkinBool(prop.param(0)))); + return AddMultiInfo(GUIInfo(SKIN_BOOL, CSkinSettings::Get().TranslateBool(prop.param(0)))); else if (prop.name == "hastheme") return AddMultiInfo(GUIInfo(SKIN_HAS_THEME, ConditionalStringParameter(prop.param(0)))); } @@ -1272,10 +1274,10 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fa strLabel.Format("%2.1f dB", CAEUtil::PercentToGain(g_settings.m_fVolumeLevel)); break; case PLAYER_SUBTITLE_DELAY: - strLabel.Format("%2.3f s", g_settings.m_currentVideoSettings.m_SubtitleDelay); + strLabel.Format("%2.3f s", CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay); break; case PLAYER_AUDIO_DELAY: - strLabel.Format("%2.3f s", g_settings.m_currentVideoSettings.m_AudioDelay); + strLabel.Format("%2.3f s", CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay); break; case PLAYER_CHAPTER: if(g_application.IsPlaying() && g_application.m_pPlayer) @@ -2444,15 +2446,15 @@ bool CGUIInfoManager::GetMultiInfoBool(const GUIInfo &info, int contextWindow, c { case SKIN_BOOL: { - bReturn = g_settings.GetSkinBool(info.GetData1()); + bReturn = CSkinSettings::Get().GetBool(info.GetData1()); } break; case SKIN_STRING: { if (info.GetData2()) - bReturn = g_settings.GetSkinString(info.GetData1()).Equals(m_stringParameters[info.GetData2()]); + bReturn = StringUtils::EqualsNoCase(CSkinSettings::Get().GetString(info.GetData1()), m_stringParameters[info.GetData2()]); else - bReturn = !g_settings.GetSkinString(info.GetData1()).IsEmpty(); + bReturn = !CSkinSettings::Get().GetString(info.GetData1()).empty(); } break; case SKIN_HAS_THEME: @@ -2638,7 +2640,7 @@ bool CGUIInfoManager::GetMultiInfoBool(const GUIInfo &info, int contextWindow, c { CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW); if (window) - bReturn = g_settings.GetWatchMode(((CGUIMediaWindow *)window)->CurrentDirectory().GetContent()) == VIDEO_SHOW_UNWATCHED; + bReturn = CMediaSettings::Get().GetWatchedMode(((CGUIMediaWindow *)window)->CurrentDirectory().GetContent()) == WatchedModeUnwatched; } } break; @@ -2845,11 +2847,11 @@ CStdString CGUIInfoManager::GetMultiInfoLabel(const GUIInfo &info, int contextWi { if (info.m_info == SKIN_STRING) { - return g_settings.GetSkinString(info.GetData1()); + return CSkinSettings::Get().GetString(info.GetData1()); } else if (info.m_info == SKIN_BOOL) { - bool bInfo = g_settings.GetSkinBool(info.GetData1()); + bool bInfo = CSkinSettings::Get().GetBool(info.GetData1()); if (bInfo) return g_localizeStrings.Get(20122); } diff --git a/xbmc/GUIPassword.cpp b/xbmc/GUIPassword.cpp index 4a70328cc0..8cbc6729bc 100644 --- a/xbmc/GUIPassword.cpp +++ b/xbmc/GUIPassword.cpp @@ -30,6 +30,7 @@ #include "Util.h" #include "settings/Settings.h" #include "settings/GUISettings.h" +#include "settings/MediaSourceSettings.h" #include "guilib/GUIWindowManager.h" #include "FileItem.h" #include "guilib/LocalizeStrings.h" @@ -92,8 +93,8 @@ bool CGUIPassword::IsItemUnlocked(CFileItem* pItem, const CStdString &strType) pItem->m_iHasLock = 1; g_passwordManager.LockSource(strType,strLabel,false); sprintf(buffer,"%i",pItem->m_iBadPwdCount); - g_settings.UpdateSource(strType, strLabel, "badpwdcount", buffer); - g_settings.SaveSources(); + CMediaSourceSettings::Get().UpdateSource(strType, strLabel, "badpwdcount", buffer); + CMediaSourceSettings::Get().Save(); break; } case 1: @@ -102,8 +103,8 @@ bool CGUIPassword::IsItemUnlocked(CFileItem* pItem, const CStdString &strType) if (0 != g_guiSettings.GetInt("masterlock.maxretries")) pItem->m_iBadPwdCount++; sprintf(buffer,"%i",pItem->m_iBadPwdCount); - g_settings.UpdateSource(strType, strLabel, "badpwdcount", buffer); - g_settings.SaveSources(); + CMediaSourceSettings::Get().UpdateSource(strType, strLabel, "badpwdcount", buffer); + CMediaSourceSettings::Get().Save(); break; } default: @@ -382,7 +383,7 @@ bool CGUIPassword::CheckMenuLock(int iWindowID) bool CGUIPassword::LockSource(const CStdString& strType, const CStdString& strName, bool bState) { - VECSOURCES* pShares = g_settings.GetSourcesFromType(strType); + VECSOURCES* pShares = CMediaSourceSettings::Get().GetSources(strType); bool bResult = false; for (IVECSOURCES it=pShares->begin();it != pShares->end();++it) { @@ -408,7 +409,7 @@ void CGUIPassword::LockSources(bool lock) const char* strType[5] = {"programs","music","video","pictures","files"}; for (int i=0;i<5;++i) { - VECSOURCES *shares = g_settings.GetSourcesFromType(strType[i]); + VECSOURCES *shares = CMediaSourceSettings::Get().GetSources(strType[i]); for (IVECSOURCES it=shares->begin();it != shares->end();++it) if (it->m_iLockMode != LOCK_MODE_EVERYONE) it->m_iHasLock = lock ? 2 : 1; @@ -423,16 +424,16 @@ void CGUIPassword::RemoveSourceLocks() const char* strType[5] = {"programs","music","video","pictures","files"}; for (int i=0;i<5;++i) { - VECSOURCES *shares = g_settings.GetSourcesFromType(strType[i]); + VECSOURCES *shares = CMediaSourceSettings::Get().GetSources(strType[i]); for (IVECSOURCES it=shares->begin();it != shares->end();++it) if (it->m_iLockMode != LOCK_MODE_EVERYONE) // remove old info { it->m_iHasLock = 0; it->m_iLockMode = LOCK_MODE_EVERYONE; - g_settings.UpdateSource(strType[i],it->strName,"lockmode","0"); // removes locks from xml + CMediaSourceSettings::Get().UpdateSource(strType[i], it->strName, "lockmode", "0"); // removes locks from xml } } - g_settings.SaveSources(); + CMediaSourceSettings::Get().Save(); CGUIMessage msg(GUI_MSG_NOTIFY_ALL,0,0, GUI_MSG_UPDATE_SOURCES); g_windowManager.SendThreadMessage(msg); } diff --git a/xbmc/MediaSource.h b/xbmc/MediaSource.h index f24124d328..cc8cf3b6c7 100644 --- a/xbmc/MediaSource.h +++ b/xbmc/MediaSource.h @@ -113,6 +113,7 @@ typedef std::vector<CMediaSource> VECSOURCES; \sa CMediaSource, VECSOURCES */ typedef std::vector<CMediaSource>::iterator IVECSOURCES; +typedef std::vector<CMediaSource>::const_iterator CIVECSOURCES; void AddOrReplace(VECSOURCES& sources, const VECSOURCES& extras); void AddOrReplace(VECSOURCES& sources, const CMediaSource& source); diff --git a/xbmc/addons/GUIDialogAddonSettings.cpp b/xbmc/addons/GUIDialogAddonSettings.cpp index dc6ec95ea9..c304dc15f5 100644 --- a/xbmc/addons/GUIDialogAddonSettings.cpp +++ b/xbmc/addons/GUIDialogAddonSettings.cpp @@ -43,6 +43,7 @@ #include "guilib/GUIKeyboardFactory.h" #include "FileItem.h" #include "settings/Settings.h" +#include "settings/MediaSourceSettings.h" #include "GUIInfoManager.h" #include "GUIUserMessages.h" #include "dialogs/GUIDialogSelect.h" @@ -331,7 +332,7 @@ bool CGUIDialogAddonSettings::ShowVirtualKeyboard(int iControl) // setup the shares VECSOURCES *shares = NULL; if (source && strcmpi(source, "") != 0) - shares = g_settings.GetSourcesFromType(source); + shares = CMediaSourceSettings::Get().GetSources(source); VECSOURCES localShares; if (!shares) diff --git a/xbmc/addons/GUIWindowAddonBrowser.cpp b/xbmc/addons/GUIWindowAddonBrowser.cpp index 09db4c68aa..d926e4a3c1 100644 --- a/xbmc/addons/GUIWindowAddonBrowser.cpp +++ b/xbmc/addons/GUIWindowAddonBrowser.cpp @@ -43,6 +43,7 @@ #include "Application.h" #include "AddonDatabase.h" #include "settings/AdvancedSettings.h" +#include "settings/MediaSourceSettings.h" #include "storage/MediaManager.h" #include "settings/GUISettings.h" #include "LangInfo.h" @@ -217,7 +218,7 @@ bool CGUIWindowAddonBrowser::OnClick(int iItem) if (item->GetPath() == "addons://install/") { // pop up filebrowser to grab an installed folder - VECSOURCES shares = g_settings.m_fileSources; + VECSOURCES shares = *CMediaSourceSettings::Get().GetSources("files"); g_mediaManager.GetLocalDrives(shares); g_mediaManager.GetNetworkLocations(shares); CStdString path; diff --git a/xbmc/cores/VideoRenderers/BaseRenderer.cpp b/xbmc/cores/VideoRenderers/BaseRenderer.cpp index bd7850dad3..7090728e31 100644 --- a/xbmc/cores/VideoRenderers/BaseRenderer.cpp +++ b/xbmc/cores/VideoRenderers/BaseRenderer.cpp @@ -24,6 +24,7 @@ #include "BaseRenderer.h" #include "settings/Settings.h" #include "settings/GUISettings.h" +#include "settings/MediaSettings.h" #include "guilib/GraphicContext.h" #include "guilib/GUIWindowManager.h" #include "utils/log.h" @@ -303,8 +304,8 @@ RESOLUTION CBaseRenderer::GetResolution() const float CBaseRenderer::GetAspectRatio() const { - float width = (float)m_sourceWidth - g_settings.m_currentVideoSettings.m_CropLeft - g_settings.m_currentVideoSettings.m_CropRight; - float height = (float)m_sourceHeight - g_settings.m_currentVideoSettings.m_CropTop - g_settings.m_currentVideoSettings.m_CropBottom; + float width = (float)m_sourceWidth - CMediaSettings::Get().GetCurrentVideoSettings().m_CropLeft - CMediaSettings::Get().GetCurrentVideoSettings().m_CropRight; + float height = (float)m_sourceHeight - CMediaSettings::Get().GetCurrentVideoSettings().m_CropTop - CMediaSettings::Get().GetCurrentVideoSettings().m_CropBottom; return m_sourceFrameRatio * width / height * m_sourceHeight / m_sourceWidth; } @@ -565,23 +566,23 @@ void CBaseRenderer::ManageDisplay() { const CRect view = g_graphicsContext.GetViewWindow(); - m_sourceRect.x1 = (float)g_settings.m_currentVideoSettings.m_CropLeft; - m_sourceRect.y1 = (float)g_settings.m_currentVideoSettings.m_CropTop; - m_sourceRect.x2 = (float)m_sourceWidth - g_settings.m_currentVideoSettings.m_CropRight; - m_sourceRect.y2 = (float)m_sourceHeight - g_settings.m_currentVideoSettings.m_CropBottom; + m_sourceRect.x1 = (float)CMediaSettings::Get().GetCurrentVideoSettings().m_CropLeft; + m_sourceRect.y1 = (float)CMediaSettings::Get().GetCurrentVideoSettings().m_CropTop; + m_sourceRect.x2 = (float)m_sourceWidth - CMediaSettings::Get().GetCurrentVideoSettings().m_CropRight; + m_sourceRect.y2 = (float)m_sourceHeight - CMediaSettings::Get().GetCurrentVideoSettings().m_CropBottom; CalcNormalDisplayRect(view.x1, view.y1, view.Width(), view.Height(), GetAspectRatio() * g_settings.m_fPixelRatio, g_settings.m_fZoomAmount, g_settings.m_fVerticalShift); } void CBaseRenderer::SetViewMode(int viewMode) { - if (viewMode < VIEW_MODE_NORMAL || viewMode > VIEW_MODE_CUSTOM) - viewMode = VIEW_MODE_NORMAL; + if (viewMode < ViewModeNormal || viewMode > ViewModeCustom) + viewMode = ViewModeNormal; if (m_iFlags & (CONF_FLAGS_FORMAT_SBS | CONF_FLAGS_FORMAT_TB)) - viewMode = VIEW_MODE_NORMAL; + viewMode = ViewModeNormal; - g_settings.m_currentVideoSettings.m_ViewMode = viewMode; + CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode = viewMode; // get our calibrated full screen resolution RESOLUTION res = GetResolution(); @@ -596,7 +597,7 @@ void CBaseRenderer::SetViewMode(int viewMode) float sourceFrameRatio = GetAspectRatio(); bool is43 = (sourceFrameRatio < 8.f/(3.f*sqrt(3.f)) && - g_settings.m_currentVideoSettings.m_ViewMode == VIEW_MODE_NORMAL); + CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode == ViewModeNormal); // Splitres scaling factor float xscale = (float)g_settings.m_ResInfo[res].iScreenWidth / (float)g_settings.m_ResInfo[res].iWidth; @@ -608,8 +609,8 @@ void CBaseRenderer::SetViewMode(int viewMode) g_settings.m_fVerticalShift = 0.0f; g_settings.m_bNonLinStretch = false; - if ( g_settings.m_currentVideoSettings.m_ViewMode == VIEW_MODE_ZOOM || - (is43 && g_guiSettings.GetInt("videoplayer.stretch43") == VIEW_MODE_ZOOM)) + if ( CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode == ViewModeZoom || + (is43 && g_guiSettings.GetInt("videoplayer.stretch43") == ViewModeZoom)) { // zoom image so no black bars g_settings.m_fPixelRatio = 1.0; // calculate the desired output ratio @@ -625,7 +626,7 @@ void CBaseRenderer::SetViewMode(int viewMode) g_settings.m_fZoomAmount = newHeight / screenHeight; } } - else if (g_settings.m_currentVideoSettings.m_ViewMode == VIEW_MODE_STRETCH_4x3) + else if (CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode == ViewModeStretch4x3) { // stretch image to 4:3 ratio g_settings.m_fZoomAmount = 1.0; if (res == RES_PAL_4x3 || res == RES_PAL60_4x3 || res == RES_NTSC_4x3 || res == RES_HDTV_480p_4x3) @@ -640,16 +641,16 @@ void CBaseRenderer::SetViewMode(int viewMode) g_settings.m_fPixelRatio = (4.0f / 3.0f) / sourceFrameRatio; } } - else if ( g_settings.m_currentVideoSettings.m_ViewMode == VIEW_MODE_WIDE_ZOOM || - (is43 && g_guiSettings.GetInt("videoplayer.stretch43") == VIEW_MODE_WIDE_ZOOM)) + else if ( CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode == ViewModeWideZoom || + (is43 && g_guiSettings.GetInt("videoplayer.stretch43") == ViewModeWideZoom)) { // super zoom float stretchAmount = (screenWidth / screenHeight) * g_settings.m_ResInfo[res].fPixelRatio / sourceFrameRatio; g_settings.m_fPixelRatio = pow(stretchAmount, float(2.0/3.0)); g_settings.m_fZoomAmount = pow(stretchAmount, float((stretchAmount < 1.0) ? -1.0/3.0 : 1.0/3.0)); g_settings.m_bNonLinStretch = true; } - else if ( g_settings.m_currentVideoSettings.m_ViewMode == VIEW_MODE_STRETCH_16x9 || - (is43 && g_guiSettings.GetInt("videoplayer.stretch43") == VIEW_MODE_STRETCH_16x9)) + else if ( CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode == ViewModeStretch16x9 || + (is43 && g_guiSettings.GetInt("videoplayer.stretch43") == ViewModeStretch16x9)) { // stretch image to 16:9 ratio g_settings.m_fZoomAmount = 1.0; if (res == RES_PAL_4x3 || res == RES_PAL60_4x3 || res == RES_NTSC_4x3 || res == RES_HDTV_480p_4x3) @@ -663,7 +664,7 @@ void CBaseRenderer::SetViewMode(int viewMode) g_settings.m_fPixelRatio = (screenWidth / screenHeight) * g_settings.m_ResInfo[res].fPixelRatio / sourceFrameRatio; } } - else if (g_settings.m_currentVideoSettings.m_ViewMode == VIEW_MODE_ORIGINAL) + else if (CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode == ViewModeOriginal) { // zoom image so that the height is the original size g_settings.m_fPixelRatio = 1.0; // get the size of the media file @@ -678,25 +679,25 @@ void CBaseRenderer::SetViewMode(int viewMode) newWidth = newHeight * outputFrameRatio; } // now work out the zoom amount so that no zoom is done - g_settings.m_fZoomAmount = (m_sourceHeight - g_settings.m_currentVideoSettings.m_CropTop - g_settings.m_currentVideoSettings.m_CropBottom) / newHeight; + g_settings.m_fZoomAmount = (m_sourceHeight - CMediaSettings::Get().GetCurrentVideoSettings().m_CropTop - CMediaSettings::Get().GetCurrentVideoSettings().m_CropBottom) / newHeight; } - else if (g_settings.m_currentVideoSettings.m_ViewMode == VIEW_MODE_CUSTOM) + else if (CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode == ViewModeCustom) { - g_settings.m_fZoomAmount = g_settings.m_currentVideoSettings.m_CustomZoomAmount; - g_settings.m_fPixelRatio = g_settings.m_currentVideoSettings.m_CustomPixelRatio; - g_settings.m_bNonLinStretch = g_settings.m_currentVideoSettings.m_CustomNonLinStretch; - g_settings.m_fVerticalShift = g_settings.m_currentVideoSettings.m_CustomVerticalShift; + g_settings.m_fZoomAmount = CMediaSettings::Get().GetCurrentVideoSettings().m_CustomZoomAmount; + g_settings.m_fPixelRatio = CMediaSettings::Get().GetCurrentVideoSettings().m_CustomPixelRatio; + g_settings.m_bNonLinStretch = CMediaSettings::Get().GetCurrentVideoSettings().m_CustomNonLinStretch; + g_settings.m_fVerticalShift = CMediaSettings::Get().GetCurrentVideoSettings().m_CustomVerticalShift; } - else // if (g_settings.m_currentVideoSettings.m_ViewMode == VIEW_MODE_NORMAL) + else // if (CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode == ViewModeNormal) { g_settings.m_fPixelRatio = 1.0; g_settings.m_fZoomAmount = 1.0; } - g_settings.m_currentVideoSettings.m_CustomZoomAmount = g_settings.m_fZoomAmount; - g_settings.m_currentVideoSettings.m_CustomPixelRatio = g_settings.m_fPixelRatio; - g_settings.m_currentVideoSettings.m_CustomNonLinStretch = g_settings.m_bNonLinStretch; - g_settings.m_currentVideoSettings.m_CustomVerticalShift = g_settings.m_fVerticalShift; + CMediaSettings::Get().GetCurrentVideoSettings().m_CustomZoomAmount = g_settings.m_fZoomAmount; + CMediaSettings::Get().GetCurrentVideoSettings().m_CustomPixelRatio = g_settings.m_fPixelRatio; + CMediaSettings::Get().GetCurrentVideoSettings().m_CustomNonLinStretch = g_settings.m_bNonLinStretch; + CMediaSettings::Get().GetCurrentVideoSettings().m_CustomVerticalShift = g_settings.m_fVerticalShift; } void CBaseRenderer::MarkDirty() diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp index 7771daf897..a3c46405cf 100644 --- a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp +++ b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp @@ -33,6 +33,7 @@ #include "settings/Settings.h" #include "settings/AdvancedSettings.h" #include "settings/GUISettings.h" +#include "settings/MediaSettings.h" #include "VideoShaders/YUV2RGBShader.h" #include "VideoShaders/VideoFilterShader.h" #include "windowing/WindowingFactory.h" @@ -292,7 +293,7 @@ bool CLinuxRendererGL::Configure(unsigned int width, unsigned int height, unsign // Calculate the input frame aspect ratio. CalculateFrameAspectRatio(d_width, d_height); ChooseBestResolution(fps); - SetViewMode(g_settings.m_currentVideoSettings.m_ViewMode); + SetViewMode(CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode); ManageDisplay(); m_bConfigured = true; @@ -835,7 +836,7 @@ void CLinuxRendererGL::UpdateVideoFilter() } } - if (m_scalingMethodGui == g_settings.m_currentVideoSettings.m_ScalingMethod && !nonLinStretchChanged) + if (m_scalingMethodGui == CMediaSettings::Get().GetCurrentVideoSettings().m_ScalingMethod && !nonLinStretchChanged) return; //recompile YUV shader when non-linear stretch is turned on/off @@ -843,7 +844,7 @@ void CLinuxRendererGL::UpdateVideoFilter() if (m_nonLinStretch || nonLinStretchChanged) m_reloadShaders = 1; - m_scalingMethodGui = g_settings.m_currentVideoSettings.m_ScalingMethod; + m_scalingMethodGui = CMediaSettings::Get().GetCurrentVideoSettings().m_ScalingMethod; m_scalingMethod = m_scalingMethodGui; if(!Supports(m_scalingMethod)) @@ -1247,8 +1248,8 @@ void CLinuxRendererGL::RenderSinglePass(int index, int field) glActiveTextureARB(GL_TEXTURE0); VerifyGLState(); - m_pYUVShader->SetBlack(g_settings.m_currentVideoSettings.m_Brightness * 0.01f - 0.5f); - m_pYUVShader->SetContrast(g_settings.m_currentVideoSettings.m_Contrast * 0.02f); + m_pYUVShader->SetBlack(CMediaSettings::Get().GetCurrentVideoSettings().m_Brightness * 0.01f - 0.5f); + m_pYUVShader->SetContrast(CMediaSettings::Get().GetCurrentVideoSettings().m_Contrast * 0.02f); m_pYUVShader->SetWidth(planes[0].texwidth); m_pYUVShader->SetHeight(planes[0].texheight); @@ -1372,8 +1373,8 @@ void CLinuxRendererGL::RenderToFBO(int index, int field) m_fbo.fbo.BeginRender(); VerifyGLState(); - m_pYUVShader->SetBlack(g_settings.m_currentVideoSettings.m_Brightness * 0.01f - 0.5f); - m_pYUVShader->SetContrast(g_settings.m_currentVideoSettings.m_Contrast * 0.02f); + m_pYUVShader->SetBlack(CMediaSettings::Get().GetCurrentVideoSettings().m_Brightness * 0.01f - 0.5f); + m_pYUVShader->SetContrast(CMediaSettings::Get().GetCurrentVideoSettings().m_Contrast * 0.02f); m_pYUVShader->SetWidth(planes[0].texwidth); m_pYUVShader->SetHeight(planes[0].texheight); m_pYUVShader->SetNonLinStretch(1.0); @@ -3098,11 +3099,11 @@ void CLinuxRendererGL::UploadRGBTexture(int source) } if (imaging==1 && - ((g_settings.m_currentVideoSettings.m_Brightness!=50) || - (g_settings.m_currentVideoSettings.m_Contrast!=50))) + ((CMediaSettings::Get().GetCurrentVideoSettings().m_Brightness!=50) || + (CMediaSettings::Get().GetCurrentVideoSettings().m_Contrast!=50))) { - GLfloat brightness = ((GLfloat)g_settings.m_currentVideoSettings.m_Brightness - 50.0f)/100.0f;; - GLfloat contrast = ((GLfloat)g_settings.m_currentVideoSettings.m_Contrast)/50.0f; + GLfloat brightness = ((GLfloat)CMediaSettings::Get().GetCurrentVideoSettings().m_Brightness - 50.0f)/100.0f;; + GLfloat contrast = ((GLfloat)CMediaSettings::Get().GetCurrentVideoSettings().m_Contrast)/50.0f; glPixelTransferf(GL_RED_SCALE , contrast); glPixelTransferf(GL_GREEN_SCALE, contrast); diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp b/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp index 3574a27e62..176d946646 100644 --- a/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp +++ b/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp @@ -35,6 +35,7 @@ #include "settings/Settings.h" #include "settings/AdvancedSettings.h" #include "settings/GUISettings.h" +#include "settings/MediaSettings.h" #include "guilib/FrameBufferObject.h" #include "VideoShaders/YUV2RGBShader.h" #include "VideoShaders/VideoFilterShader.h" @@ -174,7 +175,7 @@ bool CLinuxRendererGLES::Configure(unsigned int width, unsigned int height, unsi // Calculate the input frame aspect ratio. CalculateFrameAspectRatio(d_width, d_height); ChooseBestResolution(fps); - SetViewMode(g_settings.m_currentVideoSettings.m_ViewMode); + SetViewMode(CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode); ManageDisplay(); m_bConfigured = true; @@ -545,9 +546,9 @@ unsigned int CLinuxRendererGLES::PreInit() void CLinuxRendererGLES::UpdateVideoFilter() { - if (m_scalingMethodGui == g_settings.m_currentVideoSettings.m_ScalingMethod) + if (m_scalingMethodGui == CMediaSettings::Get().GetCurrentVideoSettings().m_ScalingMethod) return; - m_scalingMethodGui = g_settings.m_currentVideoSettings.m_ScalingMethod; + m_scalingMethodGui = CMediaSettings::Get().GetCurrentVideoSettings().m_ScalingMethod; m_scalingMethod = m_scalingMethodGui; if(!Supports(m_scalingMethod)) @@ -859,8 +860,8 @@ void CLinuxRendererGLES::RenderSinglePass(int index, int field) glActiveTexture(GL_TEXTURE0); VerifyGLState(); - m_pYUVShader->SetBlack(g_settings.m_currentVideoSettings.m_Brightness * 0.01f - 0.5f); - m_pYUVShader->SetContrast(g_settings.m_currentVideoSettings.m_Contrast * 0.02f); + m_pYUVShader->SetBlack(CMediaSettings::Get().GetCurrentVideoSettings().m_Brightness * 0.01f - 0.5f); + m_pYUVShader->SetContrast(CMediaSettings::Get().GetCurrentVideoSettings().m_Contrast * 0.02f); m_pYUVShader->SetWidth(im.width); m_pYUVShader->SetHeight(im.height); if (field == FIELD_TOP) @@ -981,8 +982,8 @@ void CLinuxRendererGLES::RenderMultiPass(int index, int field) m_fbo.BeginRender(); VerifyGLState(); - m_pYUVShader->SetBlack(g_settings.m_currentVideoSettings.m_Brightness * 0.01f - 0.5f); - m_pYUVShader->SetContrast(g_settings.m_currentVideoSettings.m_Contrast * 0.02f); + m_pYUVShader->SetBlack(CMediaSettings::Get().GetCurrentVideoSettings().m_Brightness * 0.01f - 0.5f); + m_pYUVShader->SetContrast(CMediaSettings::Get().GetCurrentVideoSettings().m_Contrast * 0.02f); m_pYUVShader->SetWidth(im.width); m_pYUVShader->SetHeight(im.height); if (field == FIELD_TOP) diff --git a/xbmc/cores/VideoRenderers/RenderManager.cpp b/xbmc/cores/VideoRenderers/RenderManager.cpp index d15424f8f0..1b761ace01 100644 --- a/xbmc/cores/VideoRenderers/RenderManager.cpp +++ b/xbmc/cores/VideoRenderers/RenderManager.cpp @@ -34,6 +34,7 @@ #include "settings/Settings.h" #include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" +#include "settings/MediaSettings.h" #if defined(HAS_GL) #include "LinuxRendererGL.h" @@ -564,8 +565,8 @@ void CXBMCRenderManager::FlipPage(volatile bool& bStop, double timestamp /* = 0L m_presentfield = sync; m_presentstep = PRESENT_FLIP; m_presentsource = source; - EDEINTERLACEMODE deinterlacemode = g_settings.m_currentVideoSettings.m_DeinterlaceMode; - EINTERLACEMETHOD interlacemethod = AutoInterlaceMethodInternal(g_settings.m_currentVideoSettings.m_InterlaceMethod); + EDEINTERLACEMODE deinterlacemode = CMediaSettings::Get().GetCurrentVideoSettings().m_DeinterlaceMode; + EINTERLACEMETHOD interlacemethod = AutoInterlaceMethodInternal(CMediaSettings::Get().GetCurrentVideoSettings().m_InterlaceMethod); bool invert = false; diff --git a/xbmc/cores/VideoRenderers/WinRenderer.cpp b/xbmc/cores/VideoRenderers/WinRenderer.cpp index f8091fd8ac..c103c2942a 100644 --- a/xbmc/cores/VideoRenderers/WinRenderer.cpp +++ b/xbmc/cores/VideoRenderers/WinRenderer.cpp @@ -24,6 +24,7 @@ #include "Util.h" #include "settings/Settings.h" #include "settings/GUISettings.h" +#include "settings/MediaSettings.h" #include "guilib/Texture.h" #include "windowing/WindowingFactory.h" #include "settings/AdvancedSettings.h" @@ -234,7 +235,7 @@ bool CWinRenderer::Configure(unsigned int width, unsigned int height, unsigned i ChooseBestResolution(fps); m_destWidth = g_settings.m_ResInfo[m_resolution].iWidth; m_destHeight = g_settings.m_ResInfo[m_resolution].iHeight; - SetViewMode(g_settings.m_currentVideoSettings.m_ViewMode); + SetViewMode(CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode); ManageDisplay(); m_bConfigured = true; @@ -582,12 +583,12 @@ void CWinRenderer::UpdatePSVideoFilter() void CWinRenderer::UpdateVideoFilter() { - if (m_scalingMethodGui == g_settings.m_currentVideoSettings.m_ScalingMethod && m_bFilterInitialized) + if (m_scalingMethodGui == CMediaSettings::Get().GetCurrentVideoSettings().m_ScalingMethod && m_bFilterInitialized) return; m_bFilterInitialized = true; - m_scalingMethodGui = g_settings.m_currentVideoSettings.m_ScalingMethod; + m_scalingMethodGui = CMediaSettings::Get().GetCurrentVideoSettings().m_ScalingMethod; m_scalingMethod = m_scalingMethodGui; if (!Supports(m_scalingMethod)) @@ -762,9 +763,9 @@ void CWinRenderer::ScaleFixedPipeline() float srcWidth = (float)srcDesc.Width; float srcHeight = (float)srcDesc.Height; - bool cbcontrol = (g_settings.m_currentVideoSettings.m_Contrast != 50.0f || g_settings.m_currentVideoSettings.m_Brightness != 50.0f); - unsigned int contrast = (unsigned int)(g_settings.m_currentVideoSettings.m_Contrast *.01f * 255.0f); // we have to divide by two here/multiply by two later - unsigned int brightness = (unsigned int)(g_settings.m_currentVideoSettings.m_Brightness * .01f * 255.0f); + bool cbcontrol = (CMediaSettings::Get().GetCurrentVideoSettings().m_Contrast != 50.0f || CMediaSettings::Get().GetCurrentVideoSettings().m_Brightness != 50.0f); + unsigned int contrast = (unsigned int)(CMediaSettings::Get().GetCurrentVideoSettings().m_Contrast *.01f * 255.0f); // we have to divide by two here/multiply by two later + unsigned int brightness = (unsigned int)(CMediaSettings::Get().GetCurrentVideoSettings().m_Brightness * .01f * 255.0f); D3DCOLOR diffuse = D3DCOLOR_ARGB(255, contrast, contrast, contrast); D3DCOLOR specular = D3DCOLOR_ARGB(255, brightness, brightness, brightness); @@ -861,8 +862,8 @@ void CWinRenderer::Stage1() if (!m_bUseHQScaler) { m_colorShader->Render(m_sourceRect, m_destRect, - g_settings.m_currentVideoSettings.m_Contrast, - g_settings.m_currentVideoSettings.m_Brightness, + CMediaSettings::Get().GetCurrentVideoSettings().m_Contrast, + CMediaSettings::Get().GetCurrentVideoSettings().m_Brightness, m_iFlags, (YUVBuffer*)m_VideoBuffers[m_iYV12RenderBuffer]); } @@ -879,8 +880,8 @@ void CWinRenderer::Stage1() CRect rtRect(0.0f, 0.0f, m_sourceWidth, m_sourceHeight); m_colorShader->Render(srcRect, rtRect, - g_settings.m_currentVideoSettings.m_Contrast, - g_settings.m_currentVideoSettings.m_Brightness, + CMediaSettings::Get().GetCurrentVideoSettings().m_Contrast, + CMediaSettings::Get().GetCurrentVideoSettings().m_Brightness, m_iFlags, (YUVBuffer*)m_VideoBuffers[m_iYV12RenderBuffer]); diff --git a/xbmc/cores/VideoRenderers/legacy/ComboRenderer.cpp b/xbmc/cores/VideoRenderers/legacy/ComboRenderer.cpp index 8980bdc3d4..78b5d72e92 100644 --- a/xbmc/cores/VideoRenderers/legacy/ComboRenderer.cpp +++ b/xbmc/cores/VideoRenderers/legacy/ComboRenderer.cpp @@ -132,10 +132,10 @@ void CComboRenderer::ManageDisplay() } // source rect - rs.left = g_settings.m_currentVideoSettings.m_CropLeft; - rs.top = g_settings.m_currentVideoSettings.m_CropTop; - rs.right = m_iSourceWidth - g_settings.m_currentVideoSettings.m_CropRight; - rs.bottom = m_iSourceHeight - g_settings.m_currentVideoSettings.m_CropBottom; + rs.left = CMediaSettings::Get().GetCurrentVideoSettings().m_CropLeft; + rs.top = CMediaSettings::Get().GetCurrentVideoSettings().m_CropTop; + rs.right = m_iSourceWidth - CMediaSettings::Get().GetCurrentVideoSettings().m_CropRight; + rs.bottom = m_iSourceHeight - CMediaSettings::Get().GetCurrentVideoSettings().m_CropBottom; CalcNormalDisplayRect(fOffsetX1, fOffsetY1, fScreenWidth, fScreenHeight, GetAspectRatio() * fPixelRatio, g_settings.m_fZoomAmount); diff --git a/xbmc/cores/amlplayer/AMLPlayer.cpp b/xbmc/cores/amlplayer/AMLPlayer.cpp index 2c2a8496b8..ba4e2a2467 100644 --- a/xbmc/cores/amlplayer/AMLPlayer.cpp +++ b/xbmc/cores/amlplayer/AMLPlayer.cpp @@ -968,7 +968,7 @@ bool CAMLPlayer::GetSubtitleVisible() void CAMLPlayer::SetSubtitleVisible(bool bVisible) { m_subtitle_show = (bVisible && m_subtitle_count); - g_settings.m_currentVideoSettings.m_SubtitleOn = bVisible; + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn = bVisible; if (m_subtitle_show && m_subtitle_count) { @@ -1436,11 +1436,11 @@ void CAMLPlayer::Process() // check for video in media content if (GetVideoStreamCount() > 0) { - SetAVDelay(g_settings.m_currentVideoSettings.m_AudioDelay); + SetAVDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay); // turn on/off subs - SetSubtitleVisible(g_settings.m_currentVideoSettings.m_SubtitleOn); - SetSubTitleDelay(g_settings.m_currentVideoSettings.m_SubtitleDelay); + SetSubtitleVisible(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn); + SetSubTitleDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay); // setup renderer for bypass. This tell renderer to get out of the way as // hw decoder will be doing the actual video rendering in a video plane @@ -2198,20 +2198,20 @@ void CAMLPlayer::SetVideoRect(const CRect &SrcRect, const CRect &DestRect) // do not do anything stupid here. // video zoom adjustment. - float zoom = g_settings.m_currentVideoSettings.m_CustomZoomAmount; + float zoom = CMediaSettings::Get().GetCurrentVideoSettings().m_CustomZoomAmount; if ((int)(zoom * 1000) != (int)(m_zoom * 1000)) { m_zoom = zoom; } // video contrast adjustment. - int contrast = g_settings.m_currentVideoSettings.m_Contrast; + int contrast = CMediaSettings::Get().GetCurrentVideoSettings().m_Contrast; if (contrast != m_contrast) { SetVideoContrast(contrast); m_contrast = contrast; } // video brightness adjustment. - int brightness = g_settings.m_currentVideoSettings.m_Brightness; + int brightness = CMediaSettings::Get().GetCurrentVideoSettings().m_Brightness; if (brightness != m_brightness) { SetVideoBrightness(brightness); @@ -2219,10 +2219,10 @@ void CAMLPlayer::SetVideoRect(const CRect &SrcRect, const CRect &DestRect) } // check if destination rect or video view mode has changed - if ((m_dst_rect != DestRect) || (m_view_mode != g_settings.m_currentVideoSettings.m_ViewMode)) + if ((m_dst_rect != DestRect) || (m_view_mode != CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode)) { m_dst_rect = DestRect; - m_view_mode = g_settings.m_currentVideoSettings.m_ViewMode; + m_view_mode = CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode; } else { diff --git a/xbmc/cores/dvdplayer/DVDAudio.cpp b/xbmc/cores/dvdplayer/DVDAudio.cpp index d46981d0af..1b31ad161f 100644 --- a/xbmc/cores/dvdplayer/DVDAudio.cpp +++ b/xbmc/cores/dvdplayer/DVDAudio.cpp @@ -27,6 +27,7 @@ #include "cores/AudioEngine/AEFactory.h" #include "cores/AudioEngine/Interfaces/AEStream.h" #include "settings/Settings.h" +#include "settings/MediaSettings.h" using namespace std; @@ -152,7 +153,7 @@ bool CDVDAudio::Create(const DVDAudioFrame &audioframe, CodecID codec, bool need m_SecondsPerByte = 0.0; m_iBufferSize = 0; - SetDynamicRangeCompression((long)(g_settings.m_currentVideoSettings.m_VolumeAmplification * 100)); + SetDynamicRangeCompression((long)(CMediaSettings::Get().GetCurrentVideoSettings().m_VolumeAmplification * 100)); if (m_pAudioCallback) RegisterAudioCallback(m_pAudioCallback); diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp index be5601c9f3..acb468ef59 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp @@ -22,6 +22,7 @@ #include "DVDCodecs/DVDCodecs.h" #include "DVDStreamInfo.h" #include "settings/GUISettings.h" +#include "settings/MediaSettings.h" #include "settings/Settings.h" #include "utils/log.h" @@ -300,7 +301,7 @@ bool CDVDAudioCodecPassthroughFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptio return false; // TODO - this is only valid for video files, and should be moved somewhere else - if( hints.channels == 2 && g_settings.m_currentVideoSettings.m_OutputToAllSpeakers ) + if( hints.channels == 2 && CMediaSettings::Get().GetCurrentVideoSettings().m_OutputToAllSpeakers ) { CLog::Log(LOGINFO, "CDVDAudioCodecPassthroughFFmpeg::Open - disabled passthrough due to video OTAS"); return false; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DXVA.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DXVA.cpp index 3c916c4275..466a03a13c 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DXVA.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DXVA.cpp @@ -39,6 +39,7 @@ #include "boost/shared_ptr.hpp" #include "utils/AutoPtrHandle.h" #include "settings/AdvancedSettings.h" +#include "settings/MediaSettings.h" #include "cores/VideoRenderers/RenderManager.h" #include "win32/WIN32Util.h" @@ -1175,8 +1176,8 @@ bool CProcessor::Open(UINT width, UINT height, unsigned int flags, unsigned int // And for those GPUs, the correct values will be calculated with the first Render() and the correct processor // will replace the one allocated here, before the user sees anything. // It's a bit inefficient, that's all. - m_deinterlace_mode = g_settings.m_currentVideoSettings.m_DeinterlaceMode; - m_interlace_method = g_renderManager.AutoInterlaceMethod(g_settings.m_currentVideoSettings.m_InterlaceMethod);; + m_deinterlace_mode = CMediaSettings::Get().GetCurrentVideoSettings().m_DeinterlaceMode; + m_interlace_method = g_renderManager.AutoInterlaceMethod(CMediaSettings::Get().GetCurrentVideoSettings().m_InterlaceMethod);; EvaluateQuirkNoDeintProcForProg(); @@ -1460,10 +1461,10 @@ bool CProcessor::Render(CRect src, CRect dst, IDirect3DSurface9* target, REFEREN // With auto deinterlacing, the Ion Gen. 1 drops some frames with deinterlacing processor + progressive flags for progressive material. // For that GPU (or when specified by an advanced setting), use the progressive processor. // This is at the expense of the switch speed when video interlacing flags change and a deinterlacing processor is actually required. - EDEINTERLACEMODE mode = g_settings.m_currentVideoSettings.m_DeinterlaceMode; + EDEINTERLACEMODE mode = CMediaSettings::Get().GetCurrentVideoSettings().m_DeinterlaceMode; if (g_advancedSettings.m_DXVANoDeintProcForProgressive || m_quirk_nodeintprocforprog) mode = (flags & RENDER_FLAG_FIELD0 || flags & RENDER_FLAG_FIELD1) ? VS_DEINTERLACEMODE_FORCE : VS_DEINTERLACEMODE_OFF; - EINTERLACEMETHOD method = g_renderManager.AutoInterlaceMethod(g_settings.m_currentVideoSettings.m_InterlaceMethod); + EINTERLACEMETHOD method = g_renderManager.AutoInterlaceMethod(CMediaSettings::Get().GetCurrentVideoSettings().m_InterlaceMethod); if(m_interlace_method != method || m_deinterlace_mode != mode || !m_process) @@ -1577,9 +1578,9 @@ bool CProcessor::Render(CRect src, CRect dst, IDirect3DSurface9* target, REFEREN blt.DestFormat.NominalRange = DXVA2_NominalRange_0_255; blt.Alpha = DXVA2_Fixed32OpaqueAlpha(); - blt.ProcAmpValues.Brightness = ConvertRange( m_brightness, g_settings.m_currentVideoSettings.m_Brightness + blt.ProcAmpValues.Brightness = ConvertRange( m_brightness, CMediaSettings::Get().GetCurrentVideoSettings().m_Brightness , 0, 100, 50); - blt.ProcAmpValues.Contrast = ConvertRange( m_contrast, g_settings.m_currentVideoSettings.m_Contrast + blt.ProcAmpValues.Contrast = ConvertRange( m_contrast, CMediaSettings::Get().GetCurrentVideoSettings().m_Contrast , 0, 100, 50); blt.ProcAmpValues.Hue = m_hue.DefaultValue; blt.ProcAmpValues.Saturation = m_saturation.DefaultValue; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp index f8d6e19301..8acacd636b 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp @@ -30,6 +30,7 @@ #include "settings/Settings.h" #include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" +#include "settings/MediaSettings.h" #include "Application.h" #include "utils/MathUtils.h" #include "DVDCodecs/DVDCodecUtils.h" @@ -514,29 +515,29 @@ void CVDPAU::CheckFeatures() SetHWUpscaling(); } - if (tmpBrightness != g_settings.m_currentVideoSettings.m_Brightness || - tmpContrast != g_settings.m_currentVideoSettings.m_Contrast) + if (tmpBrightness != CMediaSettings::Get().GetCurrentVideoSettings().m_Brightness || + tmpContrast != CMediaSettings::Get().GetCurrentVideoSettings().m_Contrast) { SetColor(); - tmpBrightness = g_settings.m_currentVideoSettings.m_Brightness; - tmpContrast = g_settings.m_currentVideoSettings.m_Contrast; + tmpBrightness = CMediaSettings::Get().GetCurrentVideoSettings().m_Brightness; + tmpContrast = CMediaSettings::Get().GetCurrentVideoSettings().m_Contrast; } - if (tmpNoiseReduction != g_settings.m_currentVideoSettings.m_NoiseReduction) + if (tmpNoiseReduction != CMediaSettings::Get().GetCurrentVideoSettings().m_NoiseReduction) { - tmpNoiseReduction = g_settings.m_currentVideoSettings.m_NoiseReduction; + tmpNoiseReduction = CMediaSettings::Get().GetCurrentVideoSettings().m_NoiseReduction; SetNoiseReduction(); } - if (tmpSharpness != g_settings.m_currentVideoSettings.m_Sharpness) + if (tmpSharpness != CMediaSettings::Get().GetCurrentVideoSettings().m_Sharpness) { - tmpSharpness = g_settings.m_currentVideoSettings.m_Sharpness; + tmpSharpness = CMediaSettings::Get().GetCurrentVideoSettings().m_Sharpness; SetSharpness(); } - if ( tmpDeintMode != g_settings.m_currentVideoSettings.m_DeinterlaceMode || - tmpDeintGUI != g_settings.m_currentVideoSettings.m_InterlaceMethod || + if ( tmpDeintMode != CMediaSettings::Get().GetCurrentVideoSettings().m_DeinterlaceMode || + tmpDeintGUI != CMediaSettings::Get().GetCurrentVideoSettings().m_InterlaceMethod || (tmpDeintGUI == VS_INTERLACEMETHOD_AUTO && tmpDeint != AutoInterlaceMethod())) { - tmpDeintMode = g_settings.m_currentVideoSettings.m_DeinterlaceMode; - tmpDeintGUI = g_settings.m_currentVideoSettings.m_InterlaceMethod; + tmpDeintMode = CMediaSettings::Get().GetCurrentVideoSettings().m_DeinterlaceMode; + tmpDeintGUI = CMediaSettings::Get().GetCurrentVideoSettings().m_InterlaceMethod; if (tmpDeintGUI == VS_INTERLACEMETHOD_AUTO) tmpDeint = AutoInterlaceMethod(); else @@ -580,10 +581,10 @@ void CVDPAU::SetColor() { VdpStatus vdp_st; - if (tmpBrightness != g_settings.m_currentVideoSettings.m_Brightness) - m_Procamp.brightness = (float)((g_settings.m_currentVideoSettings.m_Brightness)-50) / 100; - if (tmpContrast != g_settings.m_currentVideoSettings.m_Contrast) - m_Procamp.contrast = (float)((g_settings.m_currentVideoSettings.m_Contrast)+50) / 100; + if (tmpBrightness != CMediaSettings::Get().GetCurrentVideoSettings().m_Brightness) + m_Procamp.brightness = (float)((CMediaSettings::Get().GetCurrentVideoSettings().m_Brightness)-50) / 100; + if (tmpContrast != CMediaSettings::Get().GetCurrentVideoSettings().m_Contrast) + m_Procamp.contrast = (float)((CMediaSettings::Get().GetCurrentVideoSettings().m_Contrast)+50) / 100; if(vid_height >= 600 || vid_width > 1024) vdp_st = vdp_generate_csc_matrix(&m_Procamp, VDP_COLOR_STANDARD_ITUR_BT_709, &m_CSCMatrix); @@ -613,7 +614,7 @@ void CVDPAU::SetNoiseReduction() VdpVideoMixerAttribute attributes[] = { VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL }; VdpStatus vdp_st; - if (!g_settings.m_currentVideoSettings.m_NoiseReduction) + if (!CMediaSettings::Get().GetCurrentVideoSettings().m_NoiseReduction) { VdpBool enabled[]= {0}; vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled); @@ -623,8 +624,8 @@ void CVDPAU::SetNoiseReduction() VdpBool enabled[]={1}; vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled); CheckStatus(vdp_st, __LINE__); - void* nr[] = { &g_settings.m_currentVideoSettings.m_NoiseReduction }; - CLog::Log(LOGNOTICE,"Setting Noise Reduction to %f",g_settings.m_currentVideoSettings.m_NoiseReduction); + void* nr[] = { &CMediaSettings::Get().GetCurrentVideoSettings().m_NoiseReduction }; + CLog::Log(LOGNOTICE,"Setting Noise Reduction to %f",CMediaSettings::Get().GetCurrentVideoSettings().m_NoiseReduction); vdp_st = vdp_video_mixer_set_attribute_values(videoMixer, ARSIZE(attributes), attributes, nr); CheckStatus(vdp_st, __LINE__); } @@ -638,7 +639,7 @@ void CVDPAU::SetSharpness() VdpVideoMixerAttribute attributes[] = { VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL }; VdpStatus vdp_st; - if (!g_settings.m_currentVideoSettings.m_Sharpness) + if (!CMediaSettings::Get().GetCurrentVideoSettings().m_Sharpness) { VdpBool enabled[]={0}; vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled); @@ -648,8 +649,8 @@ void CVDPAU::SetSharpness() VdpBool enabled[]={1}; vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled); CheckStatus(vdp_st, __LINE__); - void* sh[] = { &g_settings.m_currentVideoSettings.m_Sharpness }; - CLog::Log(LOGNOTICE,"Setting Sharpness to %f",g_settings.m_currentVideoSettings.m_Sharpness); + void* sh[] = { &CMediaSettings::Get().GetCurrentVideoSettings().m_Sharpness }; + CLog::Log(LOGNOTICE,"Setting Sharpness to %f",CMediaSettings::Get().GetCurrentVideoSettings().m_Sharpness); vdp_st = vdp_video_mixer_set_attribute_values(videoMixer, ARSIZE(attributes), attributes, sh); CheckStatus(vdp_st, __LINE__); } @@ -671,8 +672,8 @@ void CVDPAU::SetHWUpscaling() void CVDPAU::SetDeinterlacing() { VdpStatus vdp_st; - EDEINTERLACEMODE mode = g_settings.m_currentVideoSettings.m_DeinterlaceMode; - EINTERLACEMETHOD method = g_settings.m_currentVideoSettings.m_InterlaceMethod; + EDEINTERLACEMODE mode = CMediaSettings::Get().GetCurrentVideoSettings().m_DeinterlaceMode; + EINTERLACEMETHOD method = CMediaSettings::Get().GetCurrentVideoSettings().m_InterlaceMethod; if (method == VS_INTERLACEMETHOD_AUTO) method = AutoInterlaceMethod(); @@ -1381,8 +1382,8 @@ int CVDPAU::Decode(AVCodecContext *avctx, AVFrame *pFrame) outRectVid.y1 = OutHeight; } - EDEINTERLACEMODE mode = g_settings.m_currentVideoSettings.m_DeinterlaceMode; - EINTERLACEMETHOD method = g_settings.m_currentVideoSettings.m_InterlaceMethod; + EDEINTERLACEMODE mode = CMediaSettings::Get().GetCurrentVideoSettings().m_DeinterlaceMode; + EINTERLACEMETHOD method = CMediaSettings::Get().GetCurrentVideoSettings().m_InterlaceMethod; if (method == VS_INTERLACEMETHOD_AUTO) method = AutoInterlaceMethod(); diff --git a/xbmc/cores/dvdplayer/DVDPlayer.cpp b/xbmc/cores/dvdplayer/DVDPlayer.cpp index 30f7ec3d5a..5bfe007d7f 100644 --- a/xbmc/cores/dvdplayer/DVDPlayer.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayer.cpp @@ -64,6 +64,7 @@ #include "settings/AdvancedSettings.h" #include "FileItem.h" #include "settings/GUISettings.h" +#include "settings/MediaSettings.h" #include "GUIUserMessages.h" #include "settings/Settings.h" #include "utils/log.h" @@ -138,8 +139,8 @@ std::vector<SelectionStream> CSelectionStreams::Get(StreamType type) static bool PredicateAudioPriority(const SelectionStream& lh, const SelectionStream& rh) { - PREDICATE_RETURN(lh.type_index == g_settings.m_currentVideoSettings.m_AudioStream - , rh.type_index == g_settings.m_currentVideoSettings.m_AudioStream); + PREDICATE_RETURN(lh.type_index == CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream + , rh.type_index == CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream); if(!g_guiSettings.GetString("locale.audiolanguage").Equals("original")) { @@ -161,14 +162,14 @@ static bool PredicateAudioPriority(const SelectionStream& lh, const SelectionStr static bool PredicateSubtitlePriority(const SelectionStream& lh, const SelectionStream& rh) { - if(!g_settings.m_currentVideoSettings.m_SubtitleOn) + if(!CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn) { PREDICATE_RETURN(lh.flags & CDemuxStream::FLAG_FORCED , rh.flags & CDemuxStream::FLAG_FORCED); } - PREDICATE_RETURN(lh.type_index == g_settings.m_currentVideoSettings.m_SubtitleStream - , rh.type_index == g_settings.m_currentVideoSettings.m_SubtitleStream); + PREDICATE_RETURN(lh.type_index == CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream + , rh.type_index == CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream); CStdString subtitle_language = g_langInfo.GetSubtitleLanguage(); if(!g_guiSettings.GetString("locale.subtitlelanguage").Equals("original")) @@ -617,11 +618,11 @@ bool CDVDPlayer::OpenInputStream() } } // end loop over all subtitle files - g_settings.m_currentVideoSettings.m_SubtitleCached = true; + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleCached = true; } - SetAVDelay(g_settings.m_currentVideoSettings.m_AudioDelay); - SetSubTitleDelay(g_settings.m_currentVideoSettings.m_SubtitleDelay); + SetAVDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay); + SetSubTitleDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay); m_clock.Reset(); m_dvd.Clear(); m_errorCount = 0; @@ -717,7 +718,7 @@ void CDVDPlayer::OpenDefaultStreams(bool reset) CloseAudioStream(true); // enable subtitles - m_dvdPlayerVideo.EnableSubtitle(g_settings.m_currentVideoSettings.m_SubtitleOn); + m_dvdPlayerVideo.EnableSubtitle(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn); // open subtitle stream streams = m_SelectionStreams.Get(STREAM_SUBTITLE, PredicateSubtitlePriority); @@ -925,9 +926,9 @@ void CDVDPlayer::Process() if(m_PlayerOptions.state.size() > 0) ptr->SetState(m_PlayerOptions.state); else if(CDVDInputStreamNavigator* nav = dynamic_cast<CDVDInputStreamNavigator*>(m_pInputStream)) - nav->EnableSubtitleStream(g_settings.m_currentVideoSettings.m_SubtitleOn); + nav->EnableSubtitleStream(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn); - g_settings.m_currentVideoSettings.m_SubtitleCached = true; + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleCached = true; } if(!OpenDemuxStream()) @@ -2715,7 +2716,7 @@ bool CDVDPlayer::GetSubtitleVisible() { CDVDInputStreamNavigator* pStream = (CDVDInputStreamNavigator*)m_pInputStream; if(pStream->IsInMenu()) - return g_settings.m_currentVideoSettings.m_SubtitleOn; + return CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn; else return pStream->IsSubtitleStreamEnabled(); } @@ -2725,7 +2726,7 @@ bool CDVDPlayer::GetSubtitleVisible() void CDVDPlayer::SetSubtitleVisible(bool bVisible) { - g_settings.m_currentVideoSettings.m_SubtitleOn = bVisible; + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn = bVisible; m_messenger.Put(new CDVDMsgBool(CDVDMsg::PLAYER_SET_SUBTITLESTREAM_VISIBLE, bVisible)); } diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp index b809b8202e..9ee51c01ae 100644 --- a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp @@ -23,6 +23,7 @@ #include "windowing/WindowingFactory.h" #include "settings/AdvancedSettings.h" #include "settings/GUISettings.h" +#include "settings/MediaSettings.h" #include "settings/Settings.h" #include "video/VideoReferenceClock.h" #include "utils/MathUtils.h" @@ -535,8 +536,8 @@ void CDVDPlayerVideo::Process() m_pVideoCodec->SetDropState(bRequestDrop); // ask codec to do deinterlacing if possible - EDEINTERLACEMODE mDeintMode = g_settings.m_currentVideoSettings.m_DeinterlaceMode; - EINTERLACEMETHOD mInt = g_renderManager.AutoInterlaceMethod(g_settings.m_currentVideoSettings.m_InterlaceMethod); + EDEINTERLACEMODE mDeintMode = CMediaSettings::Get().GetCurrentVideoSettings().m_DeinterlaceMode; + EINTERLACEMETHOD mInt = g_renderManager.AutoInterlaceMethod(CMediaSettings::Get().GetCurrentVideoSettings().m_InterlaceMethod); unsigned int mFilters = 0; @@ -658,7 +659,7 @@ void CDVDPlayerVideo::Process() } } - if (g_settings.m_currentVideoSettings.m_PostProcess) + if (CMediaSettings::Get().GetCurrentVideoSettings().m_PostProcess) { if (!sPostProcessType.empty()) sPostProcessType += ","; @@ -1364,7 +1365,7 @@ void CDVDPlayerVideo::AutoCrop(DVDVideoPicture *pPicture) { RECT crop; - if (g_settings.m_currentVideoSettings.m_Crop) + if (CMediaSettings::Get().GetCurrentVideoSettings().m_Crop) AutoCrop(pPicture, crop); else { // reset to defaults @@ -1386,16 +1387,16 @@ void CDVDPlayerVideo::AutoCrop(DVDVideoPicture *pPicture) //compare with hysteresis # define HYST(n, o) ((n) > (o) || (n) + 1 < (o)) - if(HYST(g_settings.m_currentVideoSettings.m_CropLeft , crop.left) - || HYST(g_settings.m_currentVideoSettings.m_CropRight , crop.right) - || HYST(g_settings.m_currentVideoSettings.m_CropTop , crop.top) - || HYST(g_settings.m_currentVideoSettings.m_CropBottom, crop.bottom)) + if(HYST(CMediaSettings::Get().GetCurrentVideoSettings().m_CropLeft , crop.left) + || HYST(CMediaSettings::Get().GetCurrentVideoSettings().m_CropRight , crop.right) + || HYST(CMediaSettings::Get().GetCurrentVideoSettings().m_CropTop , crop.top) + || HYST(CMediaSettings::Get().GetCurrentVideoSettings().m_CropBottom, crop.bottom)) { - g_settings.m_currentVideoSettings.m_CropLeft = crop.left; - g_settings.m_currentVideoSettings.m_CropRight = crop.right; - g_settings.m_currentVideoSettings.m_CropTop = crop.top; - g_settings.m_currentVideoSettings.m_CropBottom = crop.bottom; - g_renderManager.SetViewMode(g_settings.m_currentVideoSettings.m_ViewMode); + CMediaSettings::Get().GetCurrentVideoSettings().m_CropLeft = crop.left; + CMediaSettings::Get().GetCurrentVideoSettings().m_CropRight = crop.right; + CMediaSettings::Get().GetCurrentVideoSettings().m_CropTop = crop.top; + CMediaSettings::Get().GetCurrentVideoSettings().m_CropBottom = crop.bottom; + g_renderManager.SetViewMode(CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode); } # undef HYST } @@ -1403,10 +1404,10 @@ void CDVDPlayerVideo::AutoCrop(DVDVideoPicture *pPicture) void CDVDPlayerVideo::AutoCrop(DVDVideoPicture *pPicture, RECT &crop) { - crop.left = g_settings.m_currentVideoSettings.m_CropLeft; - crop.right = g_settings.m_currentVideoSettings.m_CropRight; - crop.top = g_settings.m_currentVideoSettings.m_CropTop; - crop.bottom = g_settings.m_currentVideoSettings.m_CropBottom; + crop.left = CMediaSettings::Get().GetCurrentVideoSettings().m_CropLeft; + crop.right = CMediaSettings::Get().GetCurrentVideoSettings().m_CropRight; + crop.top = CMediaSettings::Get().GetCurrentVideoSettings().m_CropTop; + crop.bottom = CMediaSettings::Get().GetCurrentVideoSettings().m_CropBottom; int black = 16; // what is black in the image int level = 8; // how high above this should we detect @@ -1561,7 +1562,7 @@ void CDVDPlayerVideo::ResetFrameRateCalc() m_iFrameRateLength = 1; m_iFrameRateErr = 0; - m_bAllowDrop = (!m_bCalcFrameRate && g_settings.m_currentVideoSettings.m_ScalingMethod != VS_SCALINGMETHOD_AUTO) || + m_bAllowDrop = (!m_bCalcFrameRate && CMediaSettings::Get().GetCurrentVideoSettings().m_ScalingMethod != VS_SCALINGMETHOD_AUTO) || g_advancedSettings.m_videoFpsDetect == 0; } @@ -1575,7 +1576,7 @@ void CDVDPlayerVideo::CalcFrameRate() //only calculate the framerate if sync playback to display is on, adjust refreshrate is on, //or scaling method is set to auto - if (!m_bCalcFrameRate && g_settings.m_currentVideoSettings.m_ScalingMethod != VS_SCALINGMETHOD_AUTO) + if (!m_bCalcFrameRate && CMediaSettings::Get().GetCurrentVideoSettings().m_ScalingMethod != VS_SCALINGMETHOD_AUTO) { ResetFrameRateCalc(); return; diff --git a/xbmc/cores/omxplayer/OMXPlayer.cpp b/xbmc/cores/omxplayer/OMXPlayer.cpp index 28addd37c0..246961d941 100644 --- a/xbmc/cores/omxplayer/OMXPlayer.cpp +++ b/xbmc/cores/omxplayer/OMXPlayer.cpp @@ -139,8 +139,8 @@ std::vector<OMXSelectionStream> COMXSelectionStreams::Get(StreamType type) static bool PredicateAudioPriority(const OMXSelectionStream& lh, const OMXSelectionStream& rh) { - PREDICATE_RETURN(lh.type_index == g_settings.m_currentVideoSettings.m_AudioStream - , rh.type_index == g_settings.m_currentVideoSettings.m_AudioStream); + PREDICATE_RETURN(lh.type_index == CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream + , rh.type_index == CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream); if(!g_guiSettings.GetString("locale.audiolanguage").Equals("original")) { @@ -162,14 +162,14 @@ static bool PredicateAudioPriority(const OMXSelectionStream& lh, const OMXSelect static bool PredicateSubtitlePriority(const OMXSelectionStream& lh, const OMXSelectionStream& rh) { - if(!g_settings.m_currentVideoSettings.m_SubtitleOn) + if(!CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn) { PREDICATE_RETURN(lh.flags & CDemuxStream::FLAG_FORCED , rh.flags & CDemuxStream::FLAG_FORCED); } - PREDICATE_RETURN(lh.type_index == g_settings.m_currentVideoSettings.m_SubtitleStream - , rh.type_index == g_settings.m_currentVideoSettings.m_SubtitleStream); + PREDICATE_RETURN(lh.type_index == CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream + , rh.type_index == CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream); CStdString subtitle_language = g_langInfo.GetSubtitleLanguage(); if(!g_guiSettings.GetString("locale.subtitlelanguage").Equals("original")) @@ -623,11 +623,11 @@ retry: } } // end loop over all subtitle files - g_settings.m_currentVideoSettings.m_SubtitleCached = true; + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleCached = true; } - SetAVDelay(g_settings.m_currentVideoSettings.m_AudioDelay); - SetSubTitleDelay(g_settings.m_currentVideoSettings.m_SubtitleDelay); + SetAVDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay); + SetSubTitleDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay); m_av_clock.Reset(); //m_av_clock.OMXReset(); m_dvd.Clear(); @@ -722,7 +722,7 @@ void COMXPlayer::OpenDefaultStreams(bool reset) CloseAudioStream(true); // enable subtitles - m_player_video.EnableSubtitle(g_settings.m_currentVideoSettings.m_SubtitleOn); + m_player_video.EnableSubtitle(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn); // open subtitle stream streams = m_SelectionStreams.Get(STREAM_SUBTITLE, PredicateSubtitlePriority); @@ -938,9 +938,9 @@ void COMXPlayer::Process() if(m_PlayerOptions.state.size() > 0) ((CDVDInputStreamNavigator*)m_pInputStream)->SetNavigatorState(m_PlayerOptions.state); else - ((CDVDInputStreamNavigator*)m_pInputStream)->EnableSubtitleStream(g_settings.m_currentVideoSettings.m_SubtitleOn); + ((CDVDInputStreamNavigator*)m_pInputStream)->EnableSubtitleStream(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn); - g_settings.m_currentVideoSettings.m_SubtitleCached = true; + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleCached = true; } if(!OpenDemuxStream()) @@ -2717,7 +2717,7 @@ bool COMXPlayer::GetSubtitleVisible() { CDVDInputStreamNavigator* pStream = (CDVDInputStreamNavigator*)m_pInputStream; if(pStream->IsInMenu()) - return g_settings.m_currentVideoSettings.m_SubtitleOn; + return CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn; else return pStream->IsSubtitleStreamEnabled(); } @@ -2727,7 +2727,7 @@ bool COMXPlayer::GetSubtitleVisible() void COMXPlayer::SetSubtitleVisible(bool bVisible) { - g_settings.m_currentVideoSettings.m_SubtitleOn = bVisible; + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn = bVisible; m_messenger.Put(new CDVDMsgBool(CDVDMsg::PLAYER_SET_SUBTITLESTREAM_VISIBLE, bVisible)); } diff --git a/xbmc/cores/omxplayer/OMXPlayerVideo.cpp b/xbmc/cores/omxplayer/OMXPlayerVideo.cpp index 3e27f4f3c7..96a44280df 100644 --- a/xbmc/cores/omxplayer/OMXPlayerVideo.cpp +++ b/xbmc/cores/omxplayer/OMXPlayerVideo.cpp @@ -111,7 +111,7 @@ bool OMXPlayerVideo::OpenStream(CDVDStreamInfo &hints) */ m_hints = hints; - m_Deinterlace = ( g_settings.m_currentVideoSettings.m_DeinterlaceMode == VS_DEINTERLACEMODE_OFF ) ? false : true; + m_Deinterlace = ( CMediaSettings::Get().GetCurrentVideoSettings().m_DeinterlaceMode == VS_DEINTERLACEMODE_OFF ) ? false : true; m_hdmi_clock_sync = (g_guiSettings.GetInt("videoplayer.adjustrefreshrate") != ADJUST_REFRESHRATE_OFF); m_started = false; m_flush = false; @@ -713,10 +713,10 @@ int OMXPlayerVideo::GetFreeSpace() void OMXPlayerVideo::SetVideoRect(const CRect &SrcRect, const CRect &DestRect) { // check if destination rect or video view mode has changed - if ((m_dst_rect != DestRect) || (m_view_mode != g_settings.m_currentVideoSettings.m_ViewMode)) + if ((m_dst_rect != DestRect) || (m_view_mode != CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode)) { m_dst_rect = DestRect; - m_view_mode = g_settings.m_currentVideoSettings.m_ViewMode; + m_view_mode = CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode; } else { diff --git a/xbmc/cores/playercorefactory/PlayerCoreFactory.cpp b/xbmc/cores/playercorefactory/PlayerCoreFactory.cpp index 949b103f1f..de800edcdb 100644 --- a/xbmc/cores/playercorefactory/PlayerCoreFactory.cpp +++ b/xbmc/cores/playercorefactory/PlayerCoreFactory.cpp @@ -30,12 +30,15 @@ #include "URL.h" #include "FileItem.h" #include "settings/AdvancedSettings.h" +#include "settings/Settings.h" #include "utils/AutoPtrHandle.h" #include "cores/ExternalPlayer/ExternalPlayer.h" #include "PlayerCoreConfig.h" #include "PlayerSelectionRule.h" #include "guilib/LocalizeStrings.h" +#define PLAYERCOREFACTORY_XML "playercorefactory.xml" + using namespace AUTOPTR; CPlayerCoreFactory::CPlayerCoreFactory() @@ -55,6 +58,12 @@ CPlayerCoreFactory& CPlayerCoreFactory::Get() return sPlayerCoreFactory; } +void CPlayerCoreFactory::OnSettingsLoaded() +{ + LoadConfiguration("special://xbmc/system/" PLAYERCOREFACTORY_XML, true); + LoadConfiguration(g_settings.GetUserDataItem(PLAYERCOREFACTORY_XML), false); +} + /* generic function to make a vector unique, removes later duplicates */ template<typename T> void unique (T &con) { diff --git a/xbmc/cores/playercorefactory/PlayerCoreFactory.h b/xbmc/cores/playercorefactory/PlayerCoreFactory.h index 2fb28b1452..0a60e0978e 100644 --- a/xbmc/cores/playercorefactory/PlayerCoreFactory.h +++ b/xbmc/cores/playercorefactory/PlayerCoreFactory.h @@ -23,6 +23,7 @@ #include "system.h" #include "cores/IPlayerCallback.h" +#include "settings/ISettingsHandler.h" #include "threads/CriticalSection.h" #include "utils/StdString.h" @@ -67,11 +68,13 @@ const PLAYERCOREID PCID_AMLPLAYER = EPC_AMLPLAYER; const PLAYERCOREID PCID_OMXPLAYER = EPC_OMXPLAYER; #endif -class CPlayerCoreFactory +class CPlayerCoreFactory : public ISettingsHandler { public: static CPlayerCoreFactory& Get(); + virtual void OnSettingsLoaded(); + PLAYERCOREID GetPlayerCore(const CStdString& strCoreName) const; CPlayerCoreConfig* GetPlayerConfig(const CStdString& strCoreName) const; CStdString GetPlayerName(const PLAYERCOREID eCore) const; @@ -89,8 +92,6 @@ public: PLAYERCOREID SelectPlayerDialog(VECPLAYERCORES &vecCores, float posX = 0, float posY = 0) const; PLAYERCOREID SelectPlayerDialog(float posX, float posY) const; - bool LoadConfiguration(const std::string &file, bool clear); - void OnPlayerDiscovered(const CStdString& id, const CStdString& name, EPLAYERCORES core); void OnPlayerRemoved(const CStdString& id); @@ -101,6 +102,8 @@ protected: virtual ~CPlayerCoreFactory(); private: + bool LoadConfiguration(const std::string &file, bool clear); + std::vector<CPlayerCoreConfig *> m_vecCoreConfigs; std::vector<CPlayerSelectionRule *> m_vecCoreSelectionRules; CCriticalSection m_section; diff --git a/xbmc/dialogs/GUIDialogContextMenu.cpp b/xbmc/dialogs/GUIDialogContextMenu.cpp index fc8cc0fe04..f09952ffcc 100644 --- a/xbmc/dialogs/GUIDialogContextMenu.cpp +++ b/xbmc/dialogs/GUIDialogContextMenu.cpp @@ -29,6 +29,7 @@ #include "Util.h" #include "utils/URIUtils.h" #include "settings/GUISettings.h" +#include "settings/MediaSourceSettings.h" #include "GUIDialogMediaSource.h" #include "settings/dialogs/GUIDialogLockSettings.h" #include "storage/MediaManager.h" @@ -457,7 +458,7 @@ bool CGUIDialogContextMenu::OnContextButton(const CStdString &type, const CFileI if (share->strName.Equals(defaultSource)) ClearDefault(type); } - g_settings.DeleteSource(type, share->strName, share->strPath); + CMediaSourceSettings::Get().DeleteSource(type, share->strName, share->strPath); } return true; } @@ -537,8 +538,8 @@ bool CGUIDialogContextMenu::OnContextButton(const CStdString &type, const CFileI if (!share->m_ignore) { - g_settings.UpdateSource(type,share->strName,"thumbnail",strThumb); - g_settings.SaveSources(); + CMediaSourceSettings::Get().UpdateSource(type,share->strName,"thumbnail",strThumb); + CMediaSourceSettings::Get().Save(); } else if (!strThumb.IsEmpty()) { // this is some sort of an auto-share, so store in the texture database @@ -563,11 +564,11 @@ bool CGUIDialogContextMenu::OnContextButton(const CStdString &type, const CFileI return false; // password entry and re-entry succeeded, write out the lock data share->m_iHasLock = 2; - g_settings.UpdateSource(type, share->strName, "lockcode", strNewPassword); + CMediaSourceSettings::Get().UpdateSource(type, share->strName, "lockcode", strNewPassword); strNewPassword.Format("%i",share->m_iLockMode); - g_settings.UpdateSource(type, share->strName, "lockmode", strNewPassword); - g_settings.UpdateSource(type, share->strName, "badpwdcount", "0"); - g_settings.SaveSources(); + CMediaSourceSettings::Get().UpdateSource(type, share->strName, "lockmode", strNewPassword); + CMediaSourceSettings::Get().UpdateSource(type, share->strName, "badpwdcount", "0"); + CMediaSourceSettings::Get().Save(); CGUIMessage msg(GUI_MSG_NOTIFY_ALL,0,0,GUI_MSG_UPDATE_SOURCES); g_windowManager.SendThreadMessage(msg); @@ -579,8 +580,8 @@ bool CGUIDialogContextMenu::OnContextButton(const CStdString &type, const CFileI if (!g_passwordManager.IsMasterLockUnlocked(true)) return false; - g_settings.UpdateSource(type, share->strName, "badpwdcount", "0"); - g_settings.SaveSources(); + CMediaSourceSettings::Get().UpdateSource(type, share->strName, "badpwdcount", "0"); + CMediaSourceSettings::Get().Save(); CGUIMessage msg(GUI_MSG_NOTIFY_ALL,0,0,GUI_MSG_UPDATE_SOURCES); g_windowManager.SendThreadMessage(msg); return true; @@ -594,10 +595,10 @@ bool CGUIDialogContextMenu::OnContextButton(const CStdString &type, const CFileI return false; share->m_iHasLock = 0; - g_settings.UpdateSource(type, share->strName, "lockmode", "0"); - g_settings.UpdateSource(type, share->strName, "lockcode", "0"); - g_settings.UpdateSource(type, share->strName, "badpwdcount", "0"); - g_settings.SaveSources(); + CMediaSourceSettings::Get().UpdateSource(type, share->strName, "lockmode", "0"); + CMediaSourceSettings::Get().UpdateSource(type, share->strName, "lockcode", "0"); + CMediaSourceSettings::Get().UpdateSource(type, share->strName, "badpwdcount", "0"); + CMediaSourceSettings::Get().Save(); CGUIMessage msg(GUI_MSG_NOTIFY_ALL,0,0,GUI_MSG_UPDATE_SOURCES); g_windowManager.SendThreadMessage(msg); return true; @@ -627,10 +628,10 @@ bool CGUIDialogContextMenu::OnContextButton(const CStdString &type, const CFileI else return false; // password ReSet and re-entry succeeded, write out the lock data - g_settings.UpdateSource(type, share->strName, "lockcode", strNewPW); - g_settings.UpdateSource(type, share->strName, "lockmode", strNewLockMode); - g_settings.UpdateSource(type, share->strName, "badpwdcount", "0"); - g_settings.SaveSources(); + CMediaSourceSettings::Get().UpdateSource(type, share->strName, "lockcode", strNewPW); + CMediaSourceSettings::Get().UpdateSource(type, share->strName, "lockmode", strNewLockMode); + CMediaSourceSettings::Get().UpdateSource(type, share->strName, "badpwdcount", "0"); + CMediaSourceSettings::Get().Save(); CGUIMessage msg(GUI_MSG_NOTIFY_ALL,0,0,GUI_MSG_UPDATE_SOURCES); g_windowManager.SendThreadMessage(msg); return true; @@ -643,7 +644,7 @@ bool CGUIDialogContextMenu::OnContextButton(const CStdString &type, const CFileI CMediaSource *CGUIDialogContextMenu::GetShare(const CStdString &type, const CFileItem *item) { - VECSOURCES *shares = g_settings.GetSourcesFromType(type); + VECSOURCES *shares = CMediaSourceSettings::Get().GetSources(type); if (!shares) return NULL; for (unsigned int i = 0; i < shares->size(); i++) { @@ -707,8 +708,8 @@ void CGUIDialogContextMenu::OnDeinitWindow(int nextWindowID) CStdString CGUIDialogContextMenu::GetDefaultShareNameByType(const CStdString &strType) { - VECSOURCES *pShares = g_settings.GetSourcesFromType(strType); - CStdString strDefault = g_settings.GetDefaultSourceFromType(strType); + VECSOURCES *pShares = CMediaSourceSettings::Get().GetSources(strType); + CStdString strDefault = CMediaSourceSettings::Get().GetDefaultSource(strType); if (!pShares) return ""; @@ -722,15 +723,8 @@ CStdString CGUIDialogContextMenu::GetDefaultShareNameByType(const CStdString &st void CGUIDialogContextMenu::SetDefault(const CStdString &strType, const CStdString &strDefault) { - if (strType == "programs") - g_settings.m_defaultProgramSource = strDefault; - else if (strType == "files") - g_settings.m_defaultFileSource = strDefault; - else if (strType == "music") - g_settings.m_defaultMusicSource = strDefault; - else if (strType == "pictures") - g_settings.m_defaultPictureSource = strDefault; - g_settings.SaveSources(); + CMediaSourceSettings::Get().SetDefaultSource(strType, strDefault); + CMediaSourceSettings::Get().Save(); } void CGUIDialogContextMenu::ClearDefault(const CStdString &strType) diff --git a/xbmc/dialogs/GUIDialogFileBrowser.cpp b/xbmc/dialogs/GUIDialogFileBrowser.cpp index 87d7bc0655..f55ba0864a 100644 --- a/xbmc/dialogs/GUIDialogFileBrowser.cpp +++ b/xbmc/dialogs/GUIDialogFileBrowser.cpp @@ -41,10 +41,12 @@ #include "settings/AdvancedSettings.h" #include "settings/Settings.h" #include "settings/GUISettings.h" +#include "settings/MediaSourceSettings.h" #include "guilib/Key.h" #include "guilib/LocalizeStrings.h" #include "utils/log.h" #include "URL.h" +#include "view/ViewState.h" using namespace XFILE; @@ -915,7 +917,7 @@ void CGUIDialogFileBrowser::OnAddMediaSource() { if (CGUIDialogMediaSource::ShowAndAddMediaSource(m_addSourceType)) { - SetSources(*g_settings.GetSourcesFromType(m_addSourceType)); + SetSources(*CMediaSourceSettings::Get().GetSources(m_addSourceType)); Update(""); } } @@ -924,7 +926,7 @@ void CGUIDialogFileBrowser::OnEditMediaSource(CFileItem* pItem) { if (CGUIDialogMediaSource::ShowAndEditMediaSource(m_addSourceType,pItem->GetLabel())) { - SetSources(*g_settings.GetSourcesFromType(m_addSourceType)); + SetSources(*CMediaSourceSettings::Get().GetSources(m_addSourceType)); Update(""); } } @@ -995,8 +997,8 @@ bool CGUIDialogFileBrowser::OnPopupMenu(int iItem) } else { - g_settings.DeleteSource(m_addSourceType,(*m_vecItems)[iItem]->GetLabel(),(*m_vecItems)[iItem]->GetPath()); - SetSources(*g_settings.GetSourcesFromType(m_addSourceType)); + CMediaSourceSettings::Get().DeleteSource(m_addSourceType,(*m_vecItems)[iItem]->GetLabel(),(*m_vecItems)[iItem]->GetPath()); + SetSources(*CMediaSourceSettings::Get().GetSources(m_addSourceType)); Update(""); } } diff --git a/xbmc/dialogs/GUIDialogMediaSource.cpp b/xbmc/dialogs/GUIDialogMediaSource.cpp index 20bdc84da7..3ca567eb01 100644 --- a/xbmc/dialogs/GUIDialogMediaSource.cpp +++ b/xbmc/dialogs/GUIDialogMediaSource.cpp @@ -33,6 +33,7 @@ #include "FileItem.h" #include "settings/Settings.h" #include "settings/GUISettings.h" +#include "settings/MediaSourceSettings.h" #include "guilib/LocalizeStrings.h" #include "PasswordManager.h" #include "URL.h" @@ -140,7 +141,7 @@ bool CGUIDialogMediaSource::ShowAndAddMediaSource(const CStdString &type) CMediaSource share; unsigned int i,j=2; bool bConfirmed=false; - VECSOURCES* pShares = g_settings.GetSourcesFromType(type); + VECSOURCES* pShares = CMediaSourceSettings::Get().GetSources(type); CStdString strName = dialog->m_name; while (!bConfirmed) { @@ -158,7 +159,7 @@ bool CGUIDialogMediaSource::ShowAndAddMediaSource(const CStdString &type) if (dialog->m_paths->Size() > 0) { share.m_strThumbnailImage = dialog->m_paths->Get(0)->GetArt("thumb"); } - g_settings.AddShare(type, share); + CMediaSourceSettings::Get().AddShare(type, share); } dialog->m_paths->Clear(); return confirmed; @@ -166,7 +167,7 @@ bool CGUIDialogMediaSource::ShowAndAddMediaSource(const CStdString &type) bool CGUIDialogMediaSource::ShowAndEditMediaSource(const CStdString &type, const CStdString&share) { - VECSOURCES* pShares = g_settings.GetSourcesFromType(type); + VECSOURCES* pShares = CMediaSourceSettings::Get().GetSources(type); if (pShares) { for (unsigned int i=0;i<pShares->size();++i) @@ -192,7 +193,7 @@ bool CGUIDialogMediaSource::ShowAndEditMediaSource(const CStdString &type, const { // yay, add this share unsigned int i,j=2; bool bConfirmed=false; - VECSOURCES* pShares = g_settings.GetSourcesFromType(type); + VECSOURCES* pShares = CMediaSourceSettings::Get().GetSources(type); CStdString strName = dialog->m_name; while (!bConfirmed) { @@ -209,7 +210,7 @@ bool CGUIDialogMediaSource::ShowAndEditMediaSource(const CStdString &type, const CMediaSource newShare; newShare.FromNameAndPaths(type, strName, dialog->GetPaths()); - g_settings.UpdateShare(type, strOldName, newShare); + CMediaSourceSettings::Get().UpdateShare(type, strOldName, newShare); } dialog->m_paths->Clear(); return confirmed; @@ -381,7 +382,7 @@ void CGUIDialogMediaSource::OnOK() CMediaSource share; share.FromNameAndPaths(m_type, m_name, GetPaths()); // hack: Need to temporarily add the share, then get path, then remove share - VECSOURCES *shares = g_settings.GetSourcesFromType(m_type); + VECSOURCES *shares = CMediaSourceSettings::Get().GetSources(m_type); if (shares) shares->push_back(share); if (share.strPath.Left(9).Equals("plugin://") || CDirectory::GetDirectory(share.strPath, items, "", DIR_FLAG_NO_FILE_DIRS | DIR_FLAG_ALLOW_PROMPT) || CGUIDialogYesNo::ShowAndGetInput(1001,1025,1003,1004)) diff --git a/xbmc/dialogs/GUIDialogSmartPlaylistRule.cpp b/xbmc/dialogs/GUIDialogSmartPlaylistRule.cpp index af9bda0556..f39d7d1c47 100644 --- a/xbmc/dialogs/GUIDialogSmartPlaylistRule.cpp +++ b/xbmc/dialogs/GUIDialogSmartPlaylistRule.cpp @@ -29,6 +29,7 @@ #include "guilib/GUIEditControl.h" #include "guilib/LocalizeStrings.h" #include "settings/Settings.h" +#include "settings/MediaSourceSettings.h" #include "storage/MediaManager.h" #include "utils/LabelFormatter.h" @@ -273,10 +274,10 @@ void CGUIDialogSmartPlaylistRule::OnBrowse() { VECSOURCES sources; if (m_type == "songs" || m_type == "mixed") - sources = *g_settings.GetSourcesFromType("music"); + sources = *CMediaSourceSettings::Get().GetSources("music"); if (m_type != "songs") { - VECSOURCES sources2 = *g_settings.GetSourcesFromType("video"); + VECSOURCES sources2 = *CMediaSourceSettings::Get().GetSources("video"); sources.insert(sources.end(),sources2.begin(),sources2.end()); } g_mediaManager.GetLocalDrives(sources); diff --git a/xbmc/filesystem/SourcesDirectory.cpp b/xbmc/filesystem/SourcesDirectory.cpp index 5d86f9e421..1d5d4e8e6d 100644 --- a/xbmc/filesystem/SourcesDirectory.cpp +++ b/xbmc/filesystem/SourcesDirectory.cpp @@ -25,6 +25,7 @@ #include "FileItem.h" #include "File.h" #include "settings/Settings.h" +#include "settings/MediaSourceSettings.h" #include "guilib/TextureManager.h" #include "storage/MediaManager.h" @@ -47,7 +48,7 @@ bool CSourcesDirectory::GetDirectory(const CStdString& strPath, CFileItemList &i URIUtils::RemoveSlashAtEnd(type); VECSOURCES sources; - VECSOURCES *sourcesFromType = g_settings.GetSourcesFromType(type); + VECSOURCES *sourcesFromType = CMediaSourceSettings::Get().GetSources(type); if (sourcesFromType) sources = *sourcesFromType; g_mediaManager.GetRemovableDrives(sources); diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeSeasons.cpp b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeSeasons.cpp index bcd13f6b42..aaaab2a7c1 100644 --- a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeSeasons.cpp +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeSeasons.cpp @@ -23,7 +23,7 @@ #include "video/VideoDatabase.h" #include "video/VideoDbUrl.h" #include "settings/GUISettings.h" -#include "settings/Settings.h" +#include "settings/MediaSettings.h" #include "FileItem.h" #include "utils/Variant.h" @@ -78,7 +78,7 @@ bool CDirectoryNodeSeasons::GetContent(CFileItemList& items) const if (items[0]->GetVideoInfoTag()->m_iSeason == 0 || items[1]->GetVideoInfoTag()->m_iSeason == 0) bFlatten = true; // flatten if one season + specials - if (iFlatten > 0 && !bFlatten && g_settings.GetWatchMode("tvshows") == VIDEO_SHOW_UNWATCHED) + if (iFlatten > 0 && !bFlatten && CMediaSettings::Get().GetWatchedMode("tvshows") == WatchedModeUnwatched) { int count = 0; for(int i = 0; i < items.Size(); i++) diff --git a/xbmc/interfaces/Builtins.cpp b/xbmc/interfaces/Builtins.cpp index 19ddecad32..06bcbb0de3 100644 --- a/xbmc/interfaces/Builtins.cpp +++ b/xbmc/interfaces/Builtins.cpp @@ -49,6 +49,8 @@ #include "utils/RssManager.h" #include "PartyModeManager.h" #include "settings/Settings.h" +#include "settings/MediaSourceSettings.h" +#include "settings/SkinSettings.h" #include "utils/StringUtils.h" #include "utils/URIUtils.h" #include "Util.h" @@ -1023,32 +1025,32 @@ int CBuiltins::Execute(const CStdString& execString) } else if (execute.Equals("skin.togglesetting")) { - int setting = g_settings.TranslateSkinBool(parameter); - g_settings.SetSkinBool(setting, !g_settings.GetSkinBool(setting)); + int setting = CSkinSettings::Get().TranslateBool(parameter); + CSkinSettings::Get().SetBool(setting, !CSkinSettings::Get().GetBool(setting)); g_settings.Save(); } else if (execute.Equals("skin.setbool") && params.size()) { if (params.size() > 1) { - int string = g_settings.TranslateSkinBool(params[0]); - g_settings.SetSkinBool(string, params[1].CompareNoCase("true") == 0); + int string = CSkinSettings::Get().TranslateBool(params[0]); + CSkinSettings::Get().SetBool(string, params[1].CompareNoCase("true") == 0); g_settings.Save(); return 0; } // default is to set it to true - int setting = g_settings.TranslateSkinBool(params[0]); - g_settings.SetSkinBool(setting, true); + int setting = CSkinSettings::Get().TranslateBool(params[0]); + CSkinSettings::Get().SetBool(setting, true); g_settings.Save(); } else if (execute.Equals("skin.reset")) { - g_settings.ResetSkinSetting(parameter); + CSkinSettings::Get().Reset(parameter); g_settings.Save(); } else if (execute.Equals("skin.resetsettings")) { - g_settings.ResetSkinSettings(); + CSkinSettings::Get().Reset(); g_settings.Save(); } else if (execute.Equals("skin.theme")) @@ -1103,40 +1105,40 @@ int CBuiltins::Execute(const CStdString& execString) int string = 0; if (params.size() > 1) { - string = g_settings.TranslateSkinString(params[0]); + string = CSkinSettings::Get().TranslateString(params[0]); if (execute.Equals("skin.setstring")) { - g_settings.SetSkinString(string, params[1]); + CSkinSettings::Get().SetString(string, params[1]); g_settings.Save(); return 0; } } else - string = g_settings.TranslateSkinString(params[0]); - CStdString value = g_settings.GetSkinString(string); + string = CSkinSettings::Get().TranslateString(params[0]); + CStdString value = CSkinSettings::Get().GetString(string); VECSOURCES localShares; g_mediaManager.GetLocalDrives(localShares); if (execute.Equals("skin.setstring")) { if (CGUIKeyboardFactory::ShowAndGetInput(value, g_localizeStrings.Get(1029), true)) - g_settings.SetSkinString(string, value); + CSkinSettings::Get().SetString(string, value); } else if (execute.Equals("skin.setnumeric")) { if (CGUIDialogNumeric::ShowAndGetNumber(value, g_localizeStrings.Get(611))) - g_settings.SetSkinString(string, value); + CSkinSettings::Get().SetString(string, value); } else if (execute.Equals("skin.setimage")) { if (CGUIDialogFileBrowser::ShowAndGetImage(localShares, g_localizeStrings.Get(1030), value)) - g_settings.SetSkinString(string, value); + CSkinSettings::Get().SetString(string, value); } else if (execute.Equals("skin.setlargeimage")) { - VECSOURCES *shares = g_settings.GetSourcesFromType("pictures"); + VECSOURCES *shares = CMediaSourceSettings::Get().GetSources("pictures"); if (!shares) shares = &localShares; if (CGUIDialogFileBrowser::ShowAndGetImage(*shares, g_localizeStrings.Get(1030), value)) - g_settings.SetSkinString(string, value); + CSkinSettings::Get().SetString(string, value); } else if (execute.Equals("skin.setfile")) { @@ -1163,9 +1165,9 @@ int CBuiltins::Execute(const CStdString& execString) if (CGUIDialogFileBrowser::ShowAndGetFile(url.Get(), strMask, TranslateType(type, true), replace, true, true, true)) { if (replace.Mid(0,9).Equals("addons://")) - g_settings.SetSkinString(string, URIUtils::GetFileName(replace)); + CSkinSettings::Get().SetString(string, URIUtils::GetFileName(replace)); else - g_settings.SetSkinString(string, replace); + CSkinSettings::Get().SetString(string, replace); } } else @@ -1184,7 +1186,7 @@ int CBuiltins::Execute(const CStdString& execString) } } if (CGUIDialogFileBrowser::ShowAndGetFile(localShares, strMask, g_localizeStrings.Get(1033), value)) - g_settings.SetSkinString(string, value); + CSkinSettings::Get().SetString(string, value); } } else // execute.Equals("skin.setpath")) @@ -1204,13 +1206,13 @@ int CBuiltins::Execute(const CStdString& execString) } } if (CGUIDialogFileBrowser::ShowAndGetDirectory(localShares, g_localizeStrings.Get(1031), value)) - g_settings.SetSkinString(string, value); + CSkinSettings::Get().SetString(string, value); } g_settings.Save(); } else if (execute.Equals("skin.setaddon") && params.size() > 1) { - int string = g_settings.TranslateSkinString(params[0]); + int string = CSkinSettings::Get().TranslateString(params[0]); vector<ADDON::TYPE> types; for (unsigned int i = 1 ; i < params.size() ; i++) { @@ -1221,7 +1223,7 @@ int CBuiltins::Execute(const CStdString& execString) CStdString result; if (types.size() > 0 && CGUIWindowAddonBrowser::SelectAddonID(types, result, true) == 1) { - g_settings.SetSkinString(string, result); + CSkinSettings::Get().SetString(string, result); g_settings.Save(); } } diff --git a/xbmc/interfaces/json-rpc/FileOperations.cpp b/xbmc/interfaces/json-rpc/FileOperations.cpp index cfc8717f1f..0b8ca264ee 100644 --- a/xbmc/interfaces/json-rpc/FileOperations.cpp +++ b/xbmc/interfaces/json-rpc/FileOperations.cpp @@ -27,6 +27,7 @@ #include "filesystem/File.h" #include "FileItem.h" #include "settings/AdvancedSettings.h" +#include "settings/MediaSourceSettings.h" #include "Util.h" #include "URL.h" #include "utils/URIUtils.h" @@ -42,7 +43,7 @@ JSONRPC_STATUS CFileOperations::GetRootDirectory(const CStdString &method, ITran CStdString media = parameterObject["media"].asString(); media = media.ToLower(); - VECSOURCES *sources = g_settings.GetSourcesFromType(media); + VECSOURCES *sources = CMediaSourceSettings::Get().GetSources(media); if (sources) { CFileItemList items; @@ -87,7 +88,7 @@ JSONRPC_STATUS CFileOperations::GetDirectory(const CStdString &method, ITranspor bool isSource; for (unsigned int index = 0; index < SourcesSize; index++) { - sources = g_settings.GetSourcesFromType(SourceNames[index]); + sources = CMediaSourceSettings::Get().GetSources(SourceNames[index]); int sourceIndex = CUtil::GetMatchingSource(strPath, *sources, isSource); if (sourceIndex >= 0 && sourceIndex < (int)sources->size() && sources->at(sourceIndex).m_iHasLock == 2) return InvalidParams; diff --git a/xbmc/interfaces/legacy/Dialog.cpp b/xbmc/interfaces/legacy/Dialog.cpp index dd2d0e4fa0..d360223cbb 100644 --- a/xbmc/interfaces/legacy/Dialog.cpp +++ b/xbmc/interfaces/legacy/Dialog.cpp @@ -8,6 +8,7 @@ #include "guilib/GUIWindowManager.h" #include "dialogs/GUIDialogFileBrowser.h" #include "dialogs/GUIDialogNumeric.h" +#include "settings/MediaSourceSettings.h" #include "settings/Settings.h" #define ACTIVE_WINDOW g_windowManager.GetActiveWindow() @@ -132,7 +133,7 @@ namespace XBMCAddon DelayedCallGuard dcguard(languageHook); CStdString value; std::string mask = maskparam; - VECSOURCES *shares = g_settings.GetSourcesFromType(s_shares); + VECSOURCES *shares = CMediaSourceSettings::Get().GetSources(s_shares); if (!shares) throw WindowException("Error: GetSourcesFromType given %s is NULL.",s_shares.c_str()); @@ -154,7 +155,7 @@ namespace XBMCAddon bool useFileDirectories, const String& defaultt ) throw (WindowException) { DelayedCallGuard dcguard(languageHook); - VECSOURCES *shares = g_settings.GetSourcesFromType(s_shares); + VECSOURCES *shares = CMediaSourceSettings::Get().GetSources(s_shares); CStdStringArray tmpret; String lmask = mask; if (!shares) diff --git a/xbmc/interfaces/legacy/Player.cpp b/xbmc/interfaces/legacy/Player.cpp index 433dea9356..7c2c375d38 100644 --- a/xbmc/interfaces/legacy/Player.cpp +++ b/xbmc/interfaces/legacy/Player.cpp @@ -24,6 +24,7 @@ #include "PlayList.h" #include "PlayListPlayer.h" #include "settings/Settings.h" +#include "settings/MediaSettings.h" #include "Application.h" #include "ApplicationMessenger.h" #include "GUIInfoManager.h" @@ -373,8 +374,8 @@ namespace XBMCAddon { g_application.m_pPlayer->SetSubtitle(nStream); g_application.m_pPlayer->SetSubtitleVisible(true); - g_settings.m_currentVideoSettings.m_SubtitleDelay = 0.0f; - g_application.m_pPlayer->SetSubTitleDelay(g_settings.m_currentVideoSettings.m_SubtitleDelay); + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay = 0.0f; + g_application.m_pPlayer->SetSubTitleDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay); } } } @@ -384,7 +385,7 @@ namespace XBMCAddon TRACE; if (g_application.m_pPlayer) { - g_settings.m_currentVideoSettings.m_SubtitleOn = bVisible != 0; + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn = bVisible != 0; g_application.m_pPlayer->SetSubtitleVisible(bVisible != 0); } } @@ -412,7 +413,7 @@ namespace XBMCAddon CLog::Log(LOGWARNING,"'xbmc.Player().disableSubtitles()' is deprecated and will be removed in future releases, please use 'xbmc.Player().showSubtitles(false)' instead"); if (g_application.m_pPlayer) { - g_settings.m_currentVideoSettings.m_SubtitleOn = false; + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn = false; g_application.m_pPlayer->SetSubtitleVisible(false); } } diff --git a/xbmc/music/GUIViewStateMusic.cpp b/xbmc/music/GUIViewStateMusic.cpp index 03cb0005f7..2046b02e14 100644 --- a/xbmc/music/GUIViewStateMusic.cpp +++ b/xbmc/music/GUIViewStateMusic.cpp @@ -23,12 +23,14 @@ #include "video/VideoDatabase.h" #include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" +#include "settings/MediaSourceSettings.h" #include "settings/Settings.h" #include "FileItem.h" #include "guilib/WindowIDs.h" #include "Util.h" #include "guilib/LocalizeStrings.h" #include "utils/log.h" +#include "view/ViewStateSettings.h" #include "filesystem/Directory.h" #include "filesystem/MusicDatabaseDirectory.h" @@ -92,16 +94,16 @@ CGUIViewStateMusicSearch::CGUIViewStateMusicSearch(const CFileItemList& items) : SetSortMethod(SORT_METHOD_TITLE); } - SetViewAsControl(g_settings.m_viewStateMusicNavSongs.m_viewMode); - - SetSortOrder(g_settings.m_viewStateMusicNavSongs.m_sortOrder); + CViewState *viewState = CViewStateSettings::Get().Get("musicnavsongs"); + SetViewAsControl(viewState->m_viewMode); + SetSortOrder(viewState->m_sortOrder); LoadViewState(items.GetPath(), WINDOW_MUSIC_NAV); } void CGUIViewStateMusicSearch::SaveViewState() { - SaveViewToDb(m_items.GetPath(), WINDOW_MUSIC_NAV, &g_settings.m_viewStateMusicNavSongs); + SaveViewToDb(m_items.GetPath(), WINDOW_MUSIC_NAV, CViewStateSettings::Get().Get("musicnavsongs")); } CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& items) : CGUIViewStateWindowMusic(items) @@ -180,10 +182,10 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item AddSortMethod(SORT_METHOD_ARTIST, 557, LABEL_MASKS("%F", "", "%A", "")); // Filename, empty | Artist, empty SetSortMethod(SORT_METHOD_ARTIST); } - - SetViewAsControl(g_settings.m_viewStateMusicNavArtists.m_viewMode); - - SetSortOrder(g_settings.m_viewStateMusicNavArtists.m_sortOrder); + + CViewState *viewState = CViewStateSettings::Get().Get("musicnavartists"); + SetViewAsControl(viewState->m_viewMode); + SetSortOrder(viewState->m_sortOrder); } break; case NODE_TYPE_ALBUM_COMPILATIONS: @@ -205,11 +207,10 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item // year AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); - SetSortMethod(g_settings.m_viewStateMusicNavAlbums.m_sortMethod); - - SetViewAsControl(g_settings.m_viewStateMusicNavAlbums.m_viewMode); - - SetSortOrder(g_settings.m_viewStateMusicNavAlbums.m_sortOrder); + CViewState *viewState = CViewStateSettings::Get().Get("musicnavalbums"); + SetSortMethod(viewState->m_sortMethod); + SetViewAsControl(viewState->m_viewMode); + SetSortOrder(viewState->m_sortOrder); } break; case NODE_TYPE_ALBUM_RECENTLY_ADDED: @@ -217,7 +218,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item AddSortMethod(SORT_METHOD_NONE, 552, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined SetSortMethod(SORT_METHOD_NONE); - SetViewAsControl(g_settings.m_viewStateMusicNavAlbums.m_viewMode); + SetViewAsControl(CViewStateSettings::Get().Get("musicnavalbums")->m_viewMode); SetSortOrder(SortOrderNone); } @@ -227,7 +228,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item AddSortMethod(SORT_METHOD_NONE, 552, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined | empty, empty SetSortMethod(SORT_METHOD_NONE); - SetViewAsControl(g_settings.m_viewStateMusicNavSongs.m_viewMode); + SetViewAsControl(CViewStateSettings::Get().Get("musicnavsongs")->m_viewMode); SetSortOrder(SortOrderNone); } @@ -237,7 +238,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined SetSortMethod(SORT_METHOD_NONE); - SetViewAsControl(g_settings.m_viewStateMusicNavAlbums.m_viewMode); + SetViewAsControl(CViewStateSettings::Get().Get("musicnavalbums")->m_viewMode); SetSortOrder(SortOrderNone); } @@ -247,7 +248,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined | empty, empty SetSortMethod(SORT_METHOD_NONE); - SetViewAsControl(g_settings.m_viewStateMusicNavAlbums.m_viewMode); + SetViewAsControl(CViewStateSettings::Get().Get("musicnavalbums")->m_viewMode); SetSortOrder(SortOrderNone); } @@ -278,12 +279,11 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item } AddSortMethod(SORT_METHOD_DURATION, 180, LABEL_MASKS("%T - %A", "%D")); // Titel, Artist, Duration| empty, empty AddSortMethod(SORT_METHOD_SONG_RATING, 563, LABEL_MASKS("%T - %A", "%R")); // Title - Artist, Rating - - SetSortMethod(g_settings.m_viewStateMusicNavSongs.m_sortMethod); - - SetViewAsControl(g_settings.m_viewStateMusicNavSongs.m_viewMode); - - SetSortOrder(g_settings.m_viewStateMusicNavSongs.m_sortOrder); + + CViewState *viewState = CViewStateSettings::Get().Get("musicnavsongs"); + SetSortMethod(viewState->m_sortMethod); + SetViewAsControl(viewState->m_viewMode); + SetSortOrder(viewState->m_sortOrder); } break; case NODE_TYPE_ALBUM_COMPILATIONS_SONGS: @@ -309,19 +309,19 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item AddSortMethod(SORT_METHOD_DURATION, 180, LABEL_MASKS("%T - %A", "%D")); // Titel, Artist, Duration| empty, empty AddSortMethod(SORT_METHOD_SONG_RATING, 563, LABEL_MASKS("%T - %A", "%R")); // Title - Artist, Rating AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%T - %A", "%Y")); // Title, Artist, Year - + + CViewState *viewState = CViewStateSettings::Get().Get("musicnavsongs"); // the "All Albums" entries always default to SORT_METHOD_ALBUM as this is most logical - user can always // change it and the change will be saved for this particular path if (dir.IsAllItem(items.GetPath())) SetSortMethod(g_guiSettings.GetBool("filelists.ignorethewhensorting") ? SORT_METHOD_ALBUM_IGNORE_THE : SORT_METHOD_ALBUM); else - SetSortMethod(g_settings.m_viewStateMusicNavSongs.m_sortMethod); + SetSortMethod(viewState->m_sortMethod); AddSortMethod(SORT_METHOD_PLAYCOUNT, 567, LABEL_MASKS("%T - %A", "%V")); // Titel - Artist, PlayCount - SetViewAsControl(g_settings.m_viewStateMusicNavSongs.m_viewMode); - - SetSortOrder(g_settings.m_viewStateMusicNavSongs.m_sortOrder); + SetViewAsControl(viewState->m_viewMode); + SetSortOrder(viewState->m_sortOrder); } break; case NODE_TYPE_SONG_TOP100: @@ -329,7 +329,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item AddSortMethod(SORT_METHOD_NONE, 576, LABEL_MASKS("%T - %A", "%V")); SetSortMethod(SORT_METHOD_PLAYCOUNT); - SetViewAsControl(g_settings.m_viewStateMusicNavSongs.m_viewMode); + SetViewAsControl(CViewStateSettings::Get().Get("musicnavsongs")->m_viewMode); SetSortOrder(SortOrderNone); } @@ -349,12 +349,12 @@ void CGUIViewStateMusicDatabase::SaveViewState() switch (NodeType) { case NODE_TYPE_ARTIST: - SaveViewToDb(m_items.GetPath(), WINDOW_MUSIC_NAV, &g_settings.m_viewStateMusicNavArtists); + SaveViewToDb(m_items.GetPath(), WINDOW_MUSIC_NAV, CViewStateSettings::Get().Get("musicnavartists")); break; case NODE_TYPE_ALBUM_COMPILATIONS: case NODE_TYPE_ALBUM: case NODE_TYPE_YEAR_ALBUM: - SaveViewToDb(m_items.GetPath(), WINDOW_MUSIC_NAV, &g_settings.m_viewStateMusicNavAlbums); + SaveViewToDb(m_items.GetPath(), WINDOW_MUSIC_NAV, CViewStateSettings::Get().Get("musicnavalbums")); break; case NODE_TYPE_ALBUM_RECENTLY_ADDED: case NODE_TYPE_ALBUM_TOP100: @@ -365,7 +365,7 @@ void CGUIViewStateMusicDatabase::SaveViewState() case NODE_TYPE_ALBUM_COMPILATIONS_SONGS: case NODE_TYPE_SONG: case NODE_TYPE_YEAR_SONG: - SaveViewToDb(m_items.GetPath(), WINDOW_MUSIC_NAV, &g_settings.m_viewStateMusicNavSongs); + SaveViewToDb(m_items.GetPath(), WINDOW_MUSIC_NAV, CViewStateSettings::Get().Get("musicnavsongs")); break; case NODE_TYPE_ALBUM_RECENTLY_PLAYED_SONGS: case NODE_TYPE_ALBUM_RECENTLY_ADDED_SONGS: @@ -405,7 +405,7 @@ CGUIViewStateMusicSmartPlaylist::CGUIViewStateMusicSmartPlaylist(const CFileItem AddSortMethod(SORT_METHOD_SONG_RATING, 563, LABEL_MASKS("%T - %A", "%R")); // Titel, Artist, Rating| empty, empty AddPlaylistOrder(items, LABEL_MASKS(strTrackLeft, strTrackRight)); - SetViewAsControl(g_settings.m_viewStateMusicNavSongs.m_viewMode); + SetViewAsControl(CViewStateSettings::Get().Get("musicnavsongs")->m_viewMode); } else if (items.GetContent() == "albums") { @@ -433,7 +433,7 @@ CGUIViewStateMusicSmartPlaylist::CGUIViewStateMusicSmartPlaylist(const CFileItem AddPlaylistOrder(items, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); - SetViewAsControl(g_settings.m_viewStateMusicNavAlbums.m_viewMode); + SetViewAsControl(CViewStateSettings::Get().Get("musicnavalbums")->m_viewMode); } else { @@ -445,7 +445,7 @@ CGUIViewStateMusicSmartPlaylist::CGUIViewStateMusicSmartPlaylist(const CFileItem void CGUIViewStateMusicSmartPlaylist::SaveViewState() { - SaveViewToDb(m_items.GetPath(), WINDOW_MUSIC_NAV, &g_settings.m_viewStateMusicNavSongs); + SaveViewToDb(m_items.GetPath(), WINDOW_MUSIC_NAV, CViewStateSettings::Get().Get("musicnavsongs")); } CGUIViewStateMusicPlaylist::CGUIViewStateMusicPlaylist(const CFileItemList& items) : CGUIViewStateWindowMusic(items) @@ -473,8 +473,9 @@ CGUIViewStateMusicPlaylist::CGUIViewStateMusicPlaylist(const CFileItemList& item AddSortMethod(SORT_METHOD_SONG_RATING, 563, LABEL_MASKS("%T - %A", "%R")); // Titel, Artist, Rating| empty, empty SetSortMethod(SORT_METHOD_PLAYLIST_ORDER); - SetViewAsControl(g_settings.m_viewStateMusicFiles.m_viewMode); - SetSortOrder(g_settings.m_viewStateMusicFiles.m_sortOrder); + CViewState *viewState = CViewStateSettings::Get().Get("musicfiles"); + SetViewAsControl(viewState->m_viewMode); + SetSortOrder(viewState->m_sortOrder); LoadViewState(items.GetPath(), WINDOW_MUSIC_FILES); } @@ -548,10 +549,14 @@ void CGUIViewStateWindowMusicNav::SaveViewState() void CGUIViewStateWindowMusicNav::AddOnlineShares() { - if (!g_advancedSettings.m_bVirtualShares) return; - for (int i = 0; i < (int)g_settings.m_musicSources.size(); ++i) + if (!g_advancedSettings.m_bVirtualShares) + return; + + VECSOURCES *musicSources = CMediaSourceSettings::Get().GetSources("music"); + + for (int i = 0; i < (int)musicSources->size(); ++i) { - CMediaSource share = g_settings.m_musicSources.at(i); + CMediaSource share = musicSources->at(i); } } @@ -636,22 +641,25 @@ CGUIViewStateWindowMusicSongs::CGUIViewStateWindowMusicSongs(const CFileItemList AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS(strTrackLeft, "%J", "%L", "%J")); // Userdefined, Date | FolderName, Date AddSortMethod(SORT_METHOD_FILE, 561, LABEL_MASKS(strTrackLeft, strTrackRight, "%L", "")); // Userdefined, Userdefined | FolderName, empty AddSortMethod(SORT_METHOD_LISTENERS,20455,LABEL_MASKS(strTrackLeft, "%W", "%L", "%W")); - SetSortMethod(g_settings.m_viewStateMusicFiles.m_sortMethod); - SetViewAsControl(g_settings.m_viewStateMusicFiles.m_viewMode); - SetSortOrder(g_settings.m_viewStateMusicFiles.m_sortOrder); + + CViewState *viewState = CViewStateSettings::Get().Get("musicfiles"); + SetSortMethod(viewState->m_sortMethod); + SetViewAsControl(viewState->m_viewMode); + SetSortOrder(viewState->m_sortOrder); } LoadViewState(items.GetPath(), WINDOW_MUSIC_FILES); } void CGUIViewStateWindowMusicSongs::SaveViewState() { - SaveViewToDb(m_items.GetPath(), WINDOW_MUSIC_FILES, &g_settings.m_viewStateMusicFiles); + SaveViewToDb(m_items.GetPath(), WINDOW_MUSIC_FILES, CViewStateSettings::Get().Get("musicfiles")); } VECSOURCES& CGUIViewStateWindowMusicSongs::GetSources() { - AddOrReplace(g_settings.m_musicSources, CGUIViewStateWindowMusic::GetSources()); - return g_settings.m_musicSources; + VECSOURCES *musicSources = CMediaSourceSettings::Get().GetSources("music"); + AddOrReplace(*musicSources, CGUIViewStateWindowMusic::GetSources()); + return *musicSources; } CGUIViewStateWindowMusicPlaylist::CGUIViewStateWindowMusicPlaylist(const CFileItemList& items) : CGUIViewStateWindowMusic(items) diff --git a/xbmc/music/dialogs/GUIDialogMusicInfo.cpp b/xbmc/music/dialogs/GUIDialogMusicInfo.cpp index 70f98cc90c..9f588bf218 100644 --- a/xbmc/music/dialogs/GUIDialogMusicInfo.cpp +++ b/xbmc/music/dialogs/GUIDialogMusicInfo.cpp @@ -33,6 +33,7 @@ #include "settings/Settings.h" #include "settings/AdvancedSettings.h" #include "settings/GUISettings.h" +#include "settings/MediaSourceSettings.h" #include "guilib/Key.h" #include "guilib/LocalizeStrings.h" #include "utils/log.h" @@ -396,7 +397,7 @@ void CGUIDialogMusicInfo::OnGetThumb() CStdString result; bool flip=false; - VECSOURCES sources(g_settings.m_musicSources); + VECSOURCES sources(*CMediaSourceSettings::Get().GetSources("music")); AddItemPathToFileBrowserSources(sources, *m_albumItem); g_mediaManager.GetLocalDrives(sources); if (!CGUIDialogFileBrowser::ShowAndGetImage(items, sources, g_localizeStrings.Get(1030), result, &flip)) @@ -493,7 +494,7 @@ void CGUIDialogMusicInfo::OnGetFanart() } CStdString result; - VECSOURCES sources(g_settings.m_musicSources); + VECSOURCES sources(*CMediaSourceSettings::Get().GetSources("music")); g_mediaManager.GetLocalDrives(sources); bool flip=false; if (!CGUIDialogFileBrowser::ShowAndGetImage(items, sources, g_localizeStrings.Get(20437), result, &flip, 20445)) diff --git a/xbmc/music/dialogs/GUIDialogSongInfo.cpp b/xbmc/music/dialogs/GUIDialogSongInfo.cpp index c0fa47579c..c5f9f4517c 100644 --- a/xbmc/music/dialogs/GUIDialogSongInfo.cpp +++ b/xbmc/music/dialogs/GUIDialogSongInfo.cpp @@ -35,6 +35,7 @@ #include "settings/Settings.h" #include "settings/AdvancedSettings.h" #include "settings/GUISettings.h" +#include "settings/MediaSourceSettings.h" #include "guilib/LocalizeStrings.h" #include "TextureCache.h" #include "music/Album.h" @@ -289,7 +290,7 @@ void CGUIDialogSongInfo::OnGetThumb() } CStdString result; - VECSOURCES sources(g_settings.m_musicSources); + VECSOURCES sources(*CMediaSourceSettings::Get().GetSources("music")); CGUIDialogMusicInfo::AddItemPathToFileBrowserSources(sources, *m_song); g_mediaManager.GetLocalDrives(sources); if (!CGUIDialogFileBrowser::ShowAndGetImage(items, sources, g_localizeStrings.Get(1030), result)) diff --git a/xbmc/music/windows/GUIWindowMusicSongs.cpp b/xbmc/music/windows/GUIWindowMusicSongs.cpp index f346483018..46c8d4c6dc 100644 --- a/xbmc/music/windows/GUIWindowMusicSongs.cpp +++ b/xbmc/music/windows/GUIWindowMusicSongs.cpp @@ -32,6 +32,7 @@ #include "storage/MediaManager.h" #include "settings/Settings.h" #include "settings/GUISettings.h" +#include "settings/MediaSourceSettings.h" #include "guilib/Key.h" #include "guilib/LocalizeStrings.h" #include "utils/log.h" @@ -81,7 +82,7 @@ bool CGUIWindowMusicSongs::OnMessage(CGUIMessage& message) // is this the first time the window is opened? if (m_vecItems->GetPath() == "?" && message.GetStringParam().IsEmpty()) - message.SetStringParam(g_settings.m_defaultMusicSource); + message.SetStringParam(CMediaSourceSettings::Get().GetDefaultSource("music")); return CGUIWindowMusicBase::OnMessage(message); } @@ -200,7 +201,7 @@ bool CGUIWindowMusicSongs::GetDirectory(const CStdString &strDirectory, CFileIte items.FilterCueItems(); CStdString label; - if (items.GetLabel().IsEmpty() && m_rootDir.IsSource(items.GetPath(), g_settings.GetSourcesFromType("music"), &label)) + if (items.GetLabel().IsEmpty() && m_rootDir.IsSource(items.GetPath(), CMediaSourceSettings::Get().GetSources("music"), &label)) items.SetLabel(label); return true; diff --git a/xbmc/network/httprequesthandler/HTTPVfsHandler.cpp b/xbmc/network/httprequesthandler/HTTPVfsHandler.cpp index b2b9ff5843..f19aa31c83 100644 --- a/xbmc/network/httprequesthandler/HTTPVfsHandler.cpp +++ b/xbmc/network/httprequesthandler/HTTPVfsHandler.cpp @@ -23,6 +23,7 @@ #include "URL.h" #include "filesystem/File.h" #include "network/WebServer.h" +#include "settings/MediaSourceSettings.h" #include "settings/Settings.h" #include "utils/URIUtils.h" @@ -58,7 +59,7 @@ int CHTTPVfsHandler::HandleHTTPRequest(const HTTPRequest &request) VECSOURCES *sources = NULL; for (unsigned int index = 0; index < size && !accessible; index++) { - sources = g_settings.GetSourcesFromType(sourceTypes[index]); + sources = CMediaSourceSettings::Get().GetSources(sourceTypes[index]); if (sources == NULL) continue; diff --git a/xbmc/network/upnp/UPnPSettings.cpp b/xbmc/network/upnp/UPnPSettings.cpp index 70a8344b5f..03b05078e8 100644 --- a/xbmc/network/upnp/UPnPSettings.cpp +++ b/xbmc/network/upnp/UPnPSettings.cpp @@ -20,6 +20,7 @@ #include "UPnPSettings.h" #include "filesystem/File.h" +#include "threads/SingleLock.h" #include "utils/log.h" #include "utils/StringUtils.h" #include "utils/XBMCTinyXML.h" @@ -51,8 +52,15 @@ CUPnPSettings& CUPnPSettings::Get() return sUPnPSettings; } +void CUPnPSettings::OnSettingsCleared() +{ + Clear(); +} + bool CUPnPSettings::Load(const std::string &file) { + CSingleLock lock(m_critical); + Clear(); if (!CFile::Exists(file)) @@ -84,6 +92,8 @@ bool CUPnPSettings::Load(const std::string &file) bool CUPnPSettings::Save(const std::string &file) const { + CSingleLock lock(m_critical); + CXBMCTinyXML doc; TiXmlElement xmlRootElement(XML_UPNP); TiXmlNode *pRoot = doc.InsertEndChild(xmlRootElement); @@ -102,6 +112,8 @@ bool CUPnPSettings::Save(const std::string &file) const void CUPnPSettings::Clear() { + CSingleLock lock(m_critical); + m_serverUUID.clear(); m_serverPort = 0; m_maxReturnedItems = 0; diff --git a/xbmc/network/upnp/UPnPSettings.h b/xbmc/network/upnp/UPnPSettings.h index 5ef286122d..4efb6f5d49 100644 --- a/xbmc/network/upnp/UPnPSettings.h +++ b/xbmc/network/upnp/UPnPSettings.h @@ -21,10 +21,15 @@ #include <string> -class CUPnPSettings +#include "settings/ISettingsHandler.h" +#include "threads/CriticalSection.h" + +class CUPnPSettings : public ISettingsHandler { public: static CUPnPSettings& Get(); + + virtual void OnSettingsCleared(); bool Load(const std::string &file); bool Save(const std::string &file) const; @@ -54,4 +59,6 @@ private: int m_maxReturnedItems; std::string m_rendererUUID; int m_rendererPort; + + CCriticalSection m_critical; }; diff --git a/xbmc/pictures/GUIViewStatePictures.cpp b/xbmc/pictures/GUIViewStatePictures.cpp index 80295b416f..621f640e77 100644 --- a/xbmc/pictures/GUIViewStatePictures.cpp +++ b/xbmc/pictures/GUIViewStatePictures.cpp @@ -24,10 +24,12 @@ #include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" #include "settings/Settings.h" +#include "settings/MediaSourceSettings.h" #include "filesystem/Directory.h" #include "filesystem/PluginDirectory.h" #include "guilib/LocalizeStrings.h" #include "guilib/WindowIDs.h" +#include "view/ViewStateSettings.h" using namespace XFILE; using namespace ADDON; @@ -51,17 +53,18 @@ CGUIViewStateWindowPictures::CGUIViewStateWindowPictures(const CFileItemList& it AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // Filename, Date | Foldername, Date AddSortMethod(SORT_METHOD_DATE_TAKEN, 577, LABEL_MASKS("%L", "%t", "%L", "%J")); // Filename, DateTaken | Foldername, Date AddSortMethod(SORT_METHOD_FILE, 561, LABEL_MASKS("%L", "%I", "%L", "")); // Filename, Size | FolderName, empty - - SetSortMethod(g_settings.m_viewStatePictures.m_sortMethod); - SetViewAsControl(g_settings.m_viewStatePictures.m_viewMode); - SetSortOrder(g_settings.m_viewStatePictures.m_sortOrder); + + CViewState *viewState = CViewStateSettings::Get().Get("pictures"); + SetSortMethod(viewState->m_sortMethod); + SetViewAsControl(viewState->m_viewMode); + SetSortOrder(viewState->m_sortOrder); } LoadViewState(items.GetPath(), WINDOW_PICTURES); } void CGUIViewStateWindowPictures::SaveViewState() { - SaveViewToDb(m_items.GetPath(), WINDOW_PICTURES, &g_settings.m_viewStatePictures); + SaveViewToDb(m_items.GetPath(), WINDOW_PICTURES, CViewStateSettings::Get().Get("pictures")); } CStdString CGUIViewStateWindowPictures::GetLockType() @@ -79,8 +82,9 @@ CStdString CGUIViewStateWindowPictures::GetExtensions() VECSOURCES& CGUIViewStateWindowPictures::GetSources() { + VECSOURCES *pictureSources = CMediaSourceSettings::Get().GetSources("pictures"); AddAddonsSource("image", g_localizeStrings.Get(1039), "DefaultAddonPicture.png"); - AddOrReplace(g_settings.m_pictureSources, CGUIViewState::GetSources()); - return g_settings.m_pictureSources; + AddOrReplace(*pictureSources, CGUIViewState::GetSources()); + return *pictureSources; } diff --git a/xbmc/pictures/GUIWindowPictures.cpp b/xbmc/pictures/GUIWindowPictures.cpp index c242b86a4a..e54450b8fc 100644 --- a/xbmc/pictures/GUIWindowPictures.cpp +++ b/xbmc/pictures/GUIWindowPictures.cpp @@ -38,6 +38,7 @@ #include "playlists/PlayList.h" #include "settings/Settings.h" #include "settings/GUISettings.h" +#include "settings/MediaSourceSettings.h" #include "utils/TimeUtils.h" #include "utils/log.h" #include "utils/URIUtils.h" @@ -107,7 +108,7 @@ bool CGUIWindowPictures::OnMessage(CGUIMessage& message) { // is this the first time accessing this window? if (m_vecItems->GetPath() == "?" && message.GetStringParam().IsEmpty()) - message.SetStringParam(g_settings.m_defaultPictureSource); + message.SetStringParam(CMediaSourceSettings::Get().GetDefaultSource("pictures")); m_dlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); @@ -304,7 +305,7 @@ bool CGUIWindowPictures::GetDirectory(const CStdString &strDirectory, CFileItemL return false; CStdString label; - if (items.GetLabel().IsEmpty() && m_rootDir.IsSource(items.GetPath(), g_settings.GetSourcesFromType("pictures"), &label)) + if (items.GetLabel().IsEmpty() && m_rootDir.IsSource(items.GetPath(), CMediaSourceSettings::Get().GetSources("pictures"), &label)) items.SetLabel(label); return true; diff --git a/xbmc/programs/GUIViewStatePrograms.cpp b/xbmc/programs/GUIViewStatePrograms.cpp index 5584fd35fd..6be388c0e1 100644 --- a/xbmc/programs/GUIViewStatePrograms.cpp +++ b/xbmc/programs/GUIViewStatePrograms.cpp @@ -23,9 +23,11 @@ #include "view/ViewState.h" #include "settings/GUISettings.h" #include "settings/Settings.h" +#include "settings/MediaSourceSettings.h" #include "filesystem/Directory.h" #include "guilib/LocalizeStrings.h" #include "guilib/WindowIDs.h" +#include "view/ViewStateSettings.h" using namespace XFILE; using namespace ADDON; @@ -36,17 +38,18 @@ CGUIViewStateWindowPrograms::CGUIViewStateWindowPrograms(const CFileItemList& it AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%K", "%I", "%L", "")); // Titel, Size | Foldername, empty else AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%K", "%I", "%L", "")); // Titel, Size | Foldername, empty - - SetSortMethod(g_settings.m_viewStatePrograms.m_sortMethod); - SetViewAsControl(g_settings.m_viewStatePrograms.m_viewMode); - SetSortOrder(g_settings.m_viewStatePrograms.m_sortOrder); + + CViewState *viewState = CViewStateSettings::Get().Get("programs"); + SetSortMethod(viewState->m_sortMethod); + SetViewAsControl(viewState->m_viewMode); + SetSortOrder(viewState->m_sortOrder); LoadViewState(items.GetPath(), WINDOW_PROGRAMS); } void CGUIViewStateWindowPrograms::SaveViewState() { - SaveViewToDb(m_items.GetPath(), WINDOW_PROGRAMS, &g_settings.m_viewStatePrograms); + SaveViewToDb(m_items.GetPath(), WINDOW_PROGRAMS, CViewStateSettings::Get().Get("programs")); } CStdString CGUIViewStateWindowPrograms::GetLockType() @@ -65,7 +68,9 @@ VECSOURCES& CGUIViewStateWindowPrograms::GetSources() #if defined(TARGET_ANDROID) AddAndroidSource("apps", g_localizeStrings.Get(20244), "DefaultProgram.png"); #endif - AddOrReplace(g_settings.m_programSources,CGUIViewState::GetSources()); - return g_settings.m_programSources; + + VECSOURCES *programSources = CMediaSourceSettings::Get().GetSources("programs"); + AddOrReplace(*programSources, CGUIViewState::GetSources()); + return *programSources; } diff --git a/xbmc/programs/GUIWindowPrograms.cpp b/xbmc/programs/GUIWindowPrograms.cpp index c4c250e8e0..57a34dba20 100644 --- a/xbmc/programs/GUIWindowPrograms.cpp +++ b/xbmc/programs/GUIWindowPrograms.cpp @@ -25,6 +25,7 @@ #include "Autorun.h" #include "guilib/GUIWindowManager.h" #include "FileItem.h" +#include "settings/MediaSourceSettings.h" #include "settings/Settings.h" #include "guilib/Key.h" #include "guilib/LocalizeStrings.h" @@ -65,7 +66,7 @@ bool CGUIWindowPrograms::OnMessage(CGUIMessage& message) // is this the first time accessing this window? if (m_vecItems->GetPath() == "?" && message.GetStringParam().IsEmpty()) - message.SetStringParam(g_settings.m_defaultProgramSource); + message.SetStringParam(CMediaSourceSettings::Get().GetDefaultSource("programs")); return CGUIMediaWindow::OnMessage(message); } diff --git a/xbmc/pvr/addons/PVRClients.cpp b/xbmc/pvr/addons/PVRClients.cpp index dc6324e15b..472ede3fd6 100644 --- a/xbmc/pvr/addons/PVRClients.cpp +++ b/xbmc/pvr/addons/PVRClients.cpp @@ -30,6 +30,7 @@ #include "pvr/PVRDatabase.h" #include "guilib/GUIWindowManager.h" #include "settings/Settings.h" +#include "settings/MediaSettings.h" #include "pvr/channels/PVRChannelGroups.h" #include "pvr/channels/PVRChannelGroupInternal.h" #include "pvr/recordings/PVRRecordings.h" @@ -1032,11 +1033,11 @@ void CPVRClients::SaveCurrentChannelSettings(void) if (!database) return; - if (g_settings.m_currentVideoSettings != g_settings.m_defaultVideoSettings) + if (CMediaSettings::Get().GetCurrentVideoSettings() != CMediaSettings::Get().GetDefaultVideoSettings()) { CLog::Log(LOGDEBUG, "PVR - %s - persisting custom channel settings for channel '%s'", __FUNCTION__, channel->ChannelName().c_str()); - database->PersistChannelSettings(*channel, g_settings.m_currentVideoSettings); + database->PersistChannelSettings(*channel, CMediaSettings::Get().GetCurrentVideoSettings()); } else { @@ -1062,63 +1063,63 @@ void CPVRClients::LoadCurrentChannelSettings(void) if (g_application.m_pPlayer) { /* set the default settings first */ - CVideoSettings loadedChannelSettings = g_settings.m_defaultVideoSettings; + CVideoSettings loadedChannelSettings = CMediaSettings::Get().GetDefaultVideoSettings(); /* try to load the settings from the database */ database->GetChannelSettings(*channel, loadedChannelSettings); - g_settings.m_currentVideoSettings = g_settings.m_defaultVideoSettings; - g_settings.m_currentVideoSettings.m_Brightness = loadedChannelSettings.m_Brightness; - g_settings.m_currentVideoSettings.m_Contrast = loadedChannelSettings.m_Contrast; - g_settings.m_currentVideoSettings.m_Gamma = loadedChannelSettings.m_Gamma; - g_settings.m_currentVideoSettings.m_Crop = loadedChannelSettings.m_Crop; - g_settings.m_currentVideoSettings.m_CropLeft = loadedChannelSettings.m_CropLeft; - g_settings.m_currentVideoSettings.m_CropRight = loadedChannelSettings.m_CropRight; - g_settings.m_currentVideoSettings.m_CropTop = loadedChannelSettings.m_CropTop; - g_settings.m_currentVideoSettings.m_CropBottom = loadedChannelSettings.m_CropBottom; - g_settings.m_currentVideoSettings.m_CustomPixelRatio = loadedChannelSettings.m_CustomPixelRatio; - g_settings.m_currentVideoSettings.m_CustomZoomAmount = loadedChannelSettings.m_CustomZoomAmount; - g_settings.m_currentVideoSettings.m_CustomVerticalShift = loadedChannelSettings.m_CustomVerticalShift; - g_settings.m_currentVideoSettings.m_NoiseReduction = loadedChannelSettings.m_NoiseReduction; - g_settings.m_currentVideoSettings.m_Sharpness = loadedChannelSettings.m_Sharpness; - g_settings.m_currentVideoSettings.m_InterlaceMethod = loadedChannelSettings.m_InterlaceMethod; - g_settings.m_currentVideoSettings.m_OutputToAllSpeakers = loadedChannelSettings.m_OutputToAllSpeakers; - g_settings.m_currentVideoSettings.m_AudioDelay = loadedChannelSettings.m_AudioDelay; - g_settings.m_currentVideoSettings.m_AudioStream = loadedChannelSettings.m_AudioStream; - g_settings.m_currentVideoSettings.m_SubtitleOn = loadedChannelSettings.m_SubtitleOn; - g_settings.m_currentVideoSettings.m_SubtitleDelay = loadedChannelSettings.m_SubtitleDelay; - g_settings.m_currentVideoSettings.m_CustomNonLinStretch = loadedChannelSettings.m_CustomNonLinStretch; - g_settings.m_currentVideoSettings.m_ScalingMethod = loadedChannelSettings.m_ScalingMethod; - g_settings.m_currentVideoSettings.m_PostProcess = loadedChannelSettings.m_PostProcess; - g_settings.m_currentVideoSettings.m_DeinterlaceMode = loadedChannelSettings.m_DeinterlaceMode; + CMediaSettings::Get().GetCurrentVideoSettings() = CMediaSettings::Get().GetDefaultVideoSettings(); + CMediaSettings::Get().GetCurrentVideoSettings().m_Brightness = loadedChannelSettings.m_Brightness; + CMediaSettings::Get().GetCurrentVideoSettings().m_Contrast = loadedChannelSettings.m_Contrast; + CMediaSettings::Get().GetCurrentVideoSettings().m_Gamma = loadedChannelSettings.m_Gamma; + CMediaSettings::Get().GetCurrentVideoSettings().m_Crop = loadedChannelSettings.m_Crop; + CMediaSettings::Get().GetCurrentVideoSettings().m_CropLeft = loadedChannelSettings.m_CropLeft; + CMediaSettings::Get().GetCurrentVideoSettings().m_CropRight = loadedChannelSettings.m_CropRight; + CMediaSettings::Get().GetCurrentVideoSettings().m_CropTop = loadedChannelSettings.m_CropTop; + CMediaSettings::Get().GetCurrentVideoSettings().m_CropBottom = loadedChannelSettings.m_CropBottom; + CMediaSettings::Get().GetCurrentVideoSettings().m_CustomPixelRatio = loadedChannelSettings.m_CustomPixelRatio; + CMediaSettings::Get().GetCurrentVideoSettings().m_CustomZoomAmount = loadedChannelSettings.m_CustomZoomAmount; + CMediaSettings::Get().GetCurrentVideoSettings().m_CustomVerticalShift = loadedChannelSettings.m_CustomVerticalShift; + CMediaSettings::Get().GetCurrentVideoSettings().m_NoiseReduction = loadedChannelSettings.m_NoiseReduction; + CMediaSettings::Get().GetCurrentVideoSettings().m_Sharpness = loadedChannelSettings.m_Sharpness; + CMediaSettings::Get().GetCurrentVideoSettings().m_InterlaceMethod = loadedChannelSettings.m_InterlaceMethod; + CMediaSettings::Get().GetCurrentVideoSettings().m_OutputToAllSpeakers = loadedChannelSettings.m_OutputToAllSpeakers; + CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay = loadedChannelSettings.m_AudioDelay; + CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream = loadedChannelSettings.m_AudioStream; + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn = loadedChannelSettings.m_SubtitleOn; + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay = loadedChannelSettings.m_SubtitleDelay; + CMediaSettings::Get().GetCurrentVideoSettings().m_CustomNonLinStretch = loadedChannelSettings.m_CustomNonLinStretch; + CMediaSettings::Get().GetCurrentVideoSettings().m_ScalingMethod = loadedChannelSettings.m_ScalingMethod; + CMediaSettings::Get().GetCurrentVideoSettings().m_PostProcess = loadedChannelSettings.m_PostProcess; + CMediaSettings::Get().GetCurrentVideoSettings().m_DeinterlaceMode = loadedChannelSettings.m_DeinterlaceMode; /* only change the view mode if it's different */ - if (g_settings.m_currentVideoSettings.m_ViewMode != loadedChannelSettings.m_ViewMode) + if (CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode != loadedChannelSettings.m_ViewMode) { - g_settings.m_currentVideoSettings.m_ViewMode = loadedChannelSettings.m_ViewMode; + CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode = loadedChannelSettings.m_ViewMode; - g_renderManager.SetViewMode(g_settings.m_currentVideoSettings.m_ViewMode); - g_settings.m_currentVideoSettings.m_CustomZoomAmount = g_settings.m_fZoomAmount; - g_settings.m_currentVideoSettings.m_CustomPixelRatio = g_settings.m_fPixelRatio; + g_renderManager.SetViewMode(CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode); + CMediaSettings::Get().GetCurrentVideoSettings().m_CustomZoomAmount = g_settings.m_fZoomAmount; + CMediaSettings::Get().GetCurrentVideoSettings().m_CustomPixelRatio = g_settings.m_fPixelRatio; } /* only change the subtitle stream, if it's different */ - if (g_settings.m_currentVideoSettings.m_SubtitleStream != loadedChannelSettings.m_SubtitleStream) + if (CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream != loadedChannelSettings.m_SubtitleStream) { - g_settings.m_currentVideoSettings.m_SubtitleStream = loadedChannelSettings.m_SubtitleStream; + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream = loadedChannelSettings.m_SubtitleStream; - g_application.m_pPlayer->SetSubtitle(g_settings.m_currentVideoSettings.m_SubtitleStream); + g_application.m_pPlayer->SetSubtitle(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream); } /* only change the audio stream if it's different */ - if (g_application.m_pPlayer->GetAudioStream() != g_settings.m_currentVideoSettings.m_AudioStream && - g_settings.m_currentVideoSettings.m_AudioStream >= 0) - g_application.m_pPlayer->SetAudioStream(g_settings.m_currentVideoSettings.m_AudioStream); - - g_application.m_pPlayer->SetAVDelay(g_settings.m_currentVideoSettings.m_AudioDelay); - g_application.m_pPlayer->SetDynamicRangeCompression((long)(g_settings.m_currentVideoSettings.m_VolumeAmplification * 100)); - g_application.m_pPlayer->SetSubtitleVisible(g_settings.m_currentVideoSettings.m_SubtitleOn); - g_application.m_pPlayer->SetSubTitleDelay(g_settings.m_currentVideoSettings.m_SubtitleDelay); + if (g_application.m_pPlayer->GetAudioStream() != CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream && + CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream >= 0) + g_application.m_pPlayer->SetAudioStream(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream); + + g_application.m_pPlayer->SetAVDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay); + g_application.m_pPlayer->SetDynamicRangeCompression((long)(CMediaSettings::Get().GetCurrentVideoSettings().m_VolumeAmplification * 100)); + g_application.m_pPlayer->SetSubtitleVisible(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn); + g_application.m_pPlayer->SetSubTitleDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay); /* settings can be saved on next channel switch */ m_bIsValidChannelSettings = true; diff --git a/xbmc/settings/AdvancedSettings.cpp b/xbmc/settings/AdvancedSettings.cpp index a85006b75d..53a9b5609f 100644 --- a/xbmc/settings/AdvancedSettings.cpp +++ b/xbmc/settings/AdvancedSettings.cpp @@ -43,6 +43,34 @@ CAdvancedSettings::CAdvancedSettings() m_initialized = false; } +void CAdvancedSettings::OnSettingsLoaded() +{ + // load advanced settings + Load(); + + // Add the list of disc stub extensions (if any) to the list of video extensions + if (!g_settings.m_discStubExtensions.IsEmpty()) + g_settings.m_videoExtensions += "|" + g_settings.m_discStubExtensions; + + // default players? + CLog::Log(LOGNOTICE, "Default DVD Player: %s", m_videoDefaultDVDPlayer.c_str()); + CLog::Log(LOGNOTICE, "Default Video Player: %s", m_videoDefaultPlayer.c_str()); + CLog::Log(LOGNOTICE, "Default Audio Player: %s", m_audioDefaultPlayer.c_str()); + + // setup any logging... + if (g_guiSettings.GetBool("debug.showloginfo")) + { + m_logLevel = std::max(m_logLevelHint, LOG_LEVEL_DEBUG_FREEMEM); + CLog::Log(LOGNOTICE, "Enabled debug logging due to GUI setting (%d)", m_logLevel); + } + else + { + m_logLevel = std::min(m_logLevelHint, LOG_LEVEL_DEBUG/*LOG_LEVEL_NORMAL*/); + CLog::Log(LOGNOTICE, "Disabled debug logging due to GUI setting. Level %d.", m_logLevel); + } + CLog::SetLogLevel(m_logLevel); +} + void CAdvancedSettings::Initialize() { m_audioHeadRoom = 0; diff --git a/xbmc/settings/AdvancedSettings.h b/xbmc/settings/AdvancedSettings.h index 4bc7cb013b..0e6f7ac090 100644 --- a/xbmc/settings/AdvancedSettings.h +++ b/xbmc/settings/AdvancedSettings.h @@ -20,6 +20,8 @@ */ #include <vector> + +#include "settings/ISettingsHandler.h" #include "utils/StdString.h" #include "utils/GlobalsHandling.h" @@ -80,13 +82,15 @@ struct RefreshVideoLatency typedef std::vector<TVShowRegexp> SETTINGS_TVSHOWLIST; -class CAdvancedSettings +class CAdvancedSettings : public ISettingsHandler { public: CAdvancedSettings(); static CAdvancedSettings* getInstance(); + virtual void OnSettingsLoaded(); + void Initialize(); bool Initialized() { return m_initialized; }; void AddSettingsFile(const CStdString &filename); diff --git a/xbmc/settings/GUISettings.cpp b/xbmc/settings/GUISettings.cpp index 751173dec2..a5a33e678a 100644 --- a/xbmc/settings/GUISettings.cpp +++ b/xbmc/settings/GUISettings.cpp @@ -773,11 +773,11 @@ void CGUISettings::Initialize() AddInt(vp, "videoplayer.errorinaspect", 22021, 0, 0, 1, 20, SPIN_CONTROL_INT_PLUS, MASK_PERCENT, TEXT_NONE); map<int,int> stretch; - stretch.insert(make_pair(630,VIEW_MODE_NORMAL)); - stretch.insert(make_pair(633,VIEW_MODE_WIDE_ZOOM)); - stretch.insert(make_pair(634,VIEW_MODE_STRETCH_16x9)); - stretch.insert(make_pair(631,VIEW_MODE_ZOOM)); - AddInt(vp, "videoplayer.stretch43", 173, VIEW_MODE_NORMAL, stretch, SPIN_CONTROL_TEXT); + stretch.insert(make_pair(630,ViewModeNormal)); + stretch.insert(make_pair(633,ViewModeWideZoom)); + stretch.insert(make_pair(634,ViewModeStretch16x9)); + stretch.insert(make_pair(631,ViewModeZoom)); + AddInt(vp, "videoplayer.stretch43", 173, ViewModeNormal, stretch, SPIN_CONTROL_TEXT); #ifdef HAVE_LIBVDPAU AddBool(NULL, "videoplayer.vdpau_allow_xrandr", 13122, false); #endif diff --git a/xbmc/settings/ISettingsHandler.h b/xbmc/settings/ISettingsHandler.h new file mode 100644 index 0000000000..15804377c3 --- /dev/null +++ b/xbmc/settings/ISettingsHandler.h @@ -0,0 +1,58 @@ +#pragma once +/* + * Copyright (C) 2013 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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/>. + * + */ + +class ISettingsHandler +{ +public: + virtual ~ISettingsHandler() { } + + /*! + \brief Settings loading has been initiated. + + \return True if the settings should be loaded, false if the loading should be aborted. + */ + virtual bool OnSettingsLoading() { return true; } + /*! + \brief Settings have been loaded. + + This callback can be used to trigger loading other settings. + */ + virtual void OnSettingsLoaded() { } + /*! + \brief Settings saving has been initiated. + + \return True if the settings should be saved, false if the saving should be aborted. + */ + virtual bool OnSettingsSaving() const { return true; } + /*! + \brief Settings have been saved. + + This callback can be used to trigger saving other settings. + */ + virtual void OnSettingsSaved() const { } + /*! + \brief Settings have been cleared. + + This callback can be used to trigger clearing any state variables + (e.g. before re-loading the settings). + */ + virtual void OnSettingsCleared() { } +}; diff --git a/xbmc/settings/ISubSettings.h b/xbmc/settings/ISubSettings.h new file mode 100644 index 0000000000..3f3b316646 --- /dev/null +++ b/xbmc/settings/ISubSettings.h @@ -0,0 +1,47 @@ +#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/>. + * + */ + +class TiXmlNode; + +class ISubSettings +{ +public: + virtual ~ISubSettings() { } + + /*! + \brief Load settings from the given XML node. + + \param settings XML node containing setting values + \return True if loading the settings was successful, false otherwise. + */ + virtual bool Load(const TiXmlNode *settings) { return true; } + /*! + \brief Save settings to the given XML node. + + \param settings XML node in which the settings will be saved + \return True if saving the settings was successful, false otherwise. + */ + virtual bool Save(TiXmlNode *settings) const { return true; } + /*! + \brief Clear any loaded setting values. + */ + virtual void Clear() { } +};
\ No newline at end of file diff --git a/xbmc/settings/Makefile b/xbmc/settings/Makefile index d77b7e95b6..35f892bd6a 100644 --- a/xbmc/settings/Makefile +++ b/xbmc/settings/Makefile @@ -1,7 +1,10 @@ SRCS=AdvancedSettings.cpp \ GUISettings.cpp \ + MediaSettings.cpp \ + MediaSourceSettings.cpp \ Profile.cpp \ Settings.cpp \ + SkinSettings.cpp \ VideoSettings.cpp \ LIB=settings.a diff --git a/xbmc/settings/MediaSettings.cpp b/xbmc/settings/MediaSettings.cpp new file mode 100644 index 0000000000..61c426713a --- /dev/null +++ b/xbmc/settings/MediaSettings.cpp @@ -0,0 +1,211 @@ +/* + * 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 "MediaSettings.h" +#include "threads/SingleLock.h" +#include "utils/log.h" +#include "utils/XBMCTinyXML.h" +#include "utils/XMLUtils.h" + +using namespace std; + +CMediaSettings::CMediaSettings() +{ + m_watchedModes["movies"] = WatchedModeAll; + m_watchedModes["tvshows"] = WatchedModeAll; + m_watchedModes["musicvideos"] = WatchedModeAll; +} + +CMediaSettings::~CMediaSettings() +{ } + +CMediaSettings& CMediaSettings::Get() +{ + static CMediaSettings sMediaSettings; + return sMediaSettings; +} + +bool CMediaSettings::Load(const TiXmlNode *settings) +{ + if (settings == NULL) + return false; + + CSingleLock lock(m_critical); + const TiXmlElement *pElement = settings->FirstChildElement("defaultvideosettings"); + if (pElement != NULL) + { + int deinterlaceMode; + bool deinterlaceModePresent = XMLUtils::GetInt(pElement, "deinterlacemode", deinterlaceMode, VS_DEINTERLACEMODE_OFF, VS_DEINTERLACEMODE_FORCE); + int interlaceMethod; + bool interlaceMethodPresent = XMLUtils::GetInt(pElement, "interlacemethod", interlaceMethod, VS_INTERLACEMETHOD_AUTO, VS_INTERLACEMETHOD_MAX); + // For smooth conversion of settings stored before the deinterlaceMode existed + if (!deinterlaceModePresent && interlaceMethodPresent) + { + if (interlaceMethod == VS_INTERLACEMETHOD_NONE) + { + deinterlaceMode = VS_DEINTERLACEMODE_OFF; + interlaceMethod = VS_INTERLACEMETHOD_AUTO; + } + else if (interlaceMethod == VS_INTERLACEMETHOD_AUTO) + deinterlaceMode = VS_DEINTERLACEMODE_AUTO; + else + deinterlaceMode = VS_DEINTERLACEMODE_FORCE; + } + m_defaultVideoSettings.m_DeinterlaceMode = (EDEINTERLACEMODE)deinterlaceMode; + m_defaultVideoSettings.m_InterlaceMethod = (EINTERLACEMETHOD)interlaceMethod; + int scalingMethod; + if (!XMLUtils::GetInt(pElement, "scalingmethod", scalingMethod, VS_SCALINGMETHOD_NEAREST, VS_SCALINGMETHOD_MAX)) + scalingMethod = (int)VS_SCALINGMETHOD_LINEAR; + m_defaultVideoSettings.m_ScalingMethod = (ESCALINGMETHOD)scalingMethod; + + XMLUtils::GetInt(pElement, "viewmode", m_defaultVideoSettings.m_ViewMode, ViewModeNormal, ViewModeCustom); + if (!XMLUtils::GetFloat(pElement, "zoomamount", m_defaultVideoSettings.m_CustomZoomAmount, 0.5f, 2.0f)) + m_defaultVideoSettings.m_CustomZoomAmount = 1.0f; + if (!XMLUtils::GetFloat(pElement, "pixelratio", m_defaultVideoSettings.m_CustomPixelRatio, 0.5f, 2.0f)) + m_defaultVideoSettings.m_CustomPixelRatio = 1.0f; + if (!XMLUtils::GetFloat(pElement, "verticalshift", m_defaultVideoSettings.m_CustomVerticalShift, -2.0f, 2.0f)) + m_defaultVideoSettings.m_CustomVerticalShift = 0.0f; + if (!XMLUtils::GetFloat(pElement, "volumeamplification", m_defaultVideoSettings.m_VolumeAmplification, VOLUME_DRC_MINIMUM * 0.01f, VOLUME_DRC_MAXIMUM * 0.01f)) + m_defaultVideoSettings.m_VolumeAmplification = VOLUME_DRC_MINIMUM * 0.01f; + if (!XMLUtils::GetFloat(pElement, "noisereduction", m_defaultVideoSettings.m_NoiseReduction, 0.0f, 1.0f)) + m_defaultVideoSettings.m_NoiseReduction = 0.0f; + XMLUtils::GetBoolean(pElement, "postprocess", m_defaultVideoSettings.m_PostProcess); + if (!XMLUtils::GetFloat(pElement, "sharpness", m_defaultVideoSettings.m_Sharpness, -1.0f, 1.0f)) + m_defaultVideoSettings.m_Sharpness = 0.0f; + XMLUtils::GetBoolean(pElement, "outputtoallspeakers", m_defaultVideoSettings.m_OutputToAllSpeakers); + XMLUtils::GetBoolean(pElement, "showsubtitles", m_defaultVideoSettings.m_SubtitleOn); + if (!XMLUtils::GetFloat(pElement, "brightness", m_defaultVideoSettings.m_Brightness, 0, 100)) + m_defaultVideoSettings.m_Brightness = 50; + if (!XMLUtils::GetFloat(pElement, "contrast", m_defaultVideoSettings.m_Contrast, 0, 100)) + m_defaultVideoSettings.m_Contrast = 50; + if (!XMLUtils::GetFloat(pElement, "gamma", m_defaultVideoSettings.m_Gamma, 0, 100)) + m_defaultVideoSettings.m_Gamma = 20; + if (!XMLUtils::GetFloat(pElement, "audiodelay", m_defaultVideoSettings.m_AudioDelay, -10.0f, 10.0f)) + m_defaultVideoSettings.m_AudioDelay = 0.0f; + if (!XMLUtils::GetFloat(pElement, "subtitledelay", m_defaultVideoSettings.m_SubtitleDelay, -10.0f, 10.0f)) + m_defaultVideoSettings.m_SubtitleDelay = 0.0f; + XMLUtils::GetBoolean(pElement, "autocrop", m_defaultVideoSettings.m_Crop); + XMLUtils::GetBoolean(pElement, "nonlinstretch", m_defaultVideoSettings.m_CustomNonLinStretch); + + m_defaultVideoSettings.m_SubtitleCached = false; + } + + // Read the watchmode settings for the various media views + pElement = settings->FirstChildElement("myvideos"); + if (pElement != NULL) + { + int tmp; + if (XMLUtils::GetInt(pElement, "watchmodemovies", tmp, (int)WatchedModeAll, (int)WatchedModeWatched)) + m_watchedModes["movies"] = (WatchedMode)tmp; + if (XMLUtils::GetInt(pElement, "watchmodetvshows", tmp, (int)WatchedModeAll, (int)WatchedModeWatched)) + m_watchedModes["tvshows"] = (WatchedMode)tmp; + if (XMLUtils::GetInt(pElement, "watchmodemusicvideos", tmp, (int)WatchedModeAll, (int)WatchedModeWatched)) + m_watchedModes["musicvideos"] = (WatchedMode)tmp; + } + + return true; +} + +bool CMediaSettings::Save(TiXmlNode *settings) const +{ + if (settings == NULL) + return false; + + CSingleLock lock(m_critical); + // default video settings + TiXmlElement videoSettingsNode("defaultvideosettings"); + TiXmlNode *pNode = settings->InsertEndChild(videoSettingsNode); + if (pNode == NULL) + return false; + + XMLUtils::SetInt(pNode, "deinterlacemode", m_defaultVideoSettings.m_DeinterlaceMode); + XMLUtils::SetInt(pNode, "interlacemethod", m_defaultVideoSettings.m_InterlaceMethod); + XMLUtils::SetInt(pNode, "scalingmethod", m_defaultVideoSettings.m_ScalingMethod); + XMLUtils::SetFloat(pNode, "noisereduction", m_defaultVideoSettings.m_NoiseReduction); + XMLUtils::SetBoolean(pNode, "postprocess", m_defaultVideoSettings.m_PostProcess); + XMLUtils::SetFloat(pNode, "sharpness", m_defaultVideoSettings.m_Sharpness); + XMLUtils::SetInt(pNode, "viewmode", m_defaultVideoSettings.m_ViewMode); + XMLUtils::SetFloat(pNode, "zoomamount", m_defaultVideoSettings.m_CustomZoomAmount); + XMLUtils::SetFloat(pNode, "pixelratio", m_defaultVideoSettings.m_CustomPixelRatio); + XMLUtils::SetFloat(pNode, "verticalshift", m_defaultVideoSettings.m_CustomVerticalShift); + XMLUtils::SetFloat(pNode, "volumeamplification", m_defaultVideoSettings.m_VolumeAmplification); + XMLUtils::SetBoolean(pNode, "outputtoallspeakers", m_defaultVideoSettings.m_OutputToAllSpeakers); + XMLUtils::SetBoolean(pNode, "showsubtitles", m_defaultVideoSettings.m_SubtitleOn); + XMLUtils::SetFloat(pNode, "brightness", m_defaultVideoSettings.m_Brightness); + XMLUtils::SetFloat(pNode, "contrast", m_defaultVideoSettings.m_Contrast); + XMLUtils::SetFloat(pNode, "gamma", m_defaultVideoSettings.m_Gamma); + XMLUtils::SetFloat(pNode, "audiodelay", m_defaultVideoSettings.m_AudioDelay); + XMLUtils::SetFloat(pNode, "subtitledelay", m_defaultVideoSettings.m_SubtitleDelay); + XMLUtils::SetBoolean(pNode, "autocrop", m_defaultVideoSettings.m_Crop); + XMLUtils::SetBoolean(pNode, "nonlinstretch", m_defaultVideoSettings.m_CustomNonLinStretch); + + pNode = settings->FirstChild("myvideos"); + if (pNode == NULL) + { + TiXmlElement videosNode("myvideos"); + pNode = settings->InsertEndChild(videosNode); + if (pNode == NULL) + return false; + } + + XMLUtils::SetInt(pNode, "watchmodemovies", m_watchedModes.find("movies")->second); + XMLUtils::SetInt(pNode, "watchmodetvshows", m_watchedModes.find("tvshows")->second); + XMLUtils::SetInt(pNode, "watchmodemusicvideos", m_watchedModes.find("musicvideos")->second); + + return true; +} + +int CMediaSettings::GetWatchedMode(const std::string &content) const +{ + CSingleLock lock(m_critical); + WatchedModes::const_iterator it = m_watchedModes.find(GetWatchedContent(content)); + if (it != m_watchedModes.end()) + return it->second; + + return WatchedModeAll; +} + +void CMediaSettings::SetWatchedMode(const std::string &content, WatchedMode mode) +{ + CSingleLock lock(m_critical); + WatchedModes::iterator it = m_watchedModes.find(GetWatchedContent(content)); + if (it != m_watchedModes.end()) + it->second = mode; +} + +void CMediaSettings::CycleWatchedMode(const std::string &content) +{ + CSingleLock lock(m_critical); + WatchedModes::iterator it = m_watchedModes.find(GetWatchedContent(content)); + if (it != m_watchedModes.end()) + { + it->second = (WatchedMode)((int)it->second + 1); + if (it->second > WatchedModeWatched) + it->second = WatchedModeAll; + } +} + +std::string CMediaSettings::GetWatchedContent(const std::string &content) +{ + if (content == "seasons" || content == "episodes") + return "tvshows"; + + return content; +} diff --git a/xbmc/settings/MediaSettings.h b/xbmc/settings/MediaSettings.h new file mode 100644 index 0000000000..9b29fc7268 --- /dev/null +++ b/xbmc/settings/MediaSettings.h @@ -0,0 +1,89 @@ +#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 <map> +#include <string> + +#include "settings/ISubSettings.h" +#include "settings/VideoSettings.h" +#include "threads/CriticalSection.h" + +#define VOLUME_DRC_MINIMUM 0 // 0dB +#define VOLUME_DRC_MAXIMUM 6000 // 60dB + +class TiXmlNode; + +typedef enum { + WatchedModeAll = 0, + WatchedModeUnwatched, + WatchedModeWatched +} WatchedMode; + +class CMediaSettings : public ISubSettings +{ +public: + static CMediaSettings& Get(); + + virtual bool Load(const TiXmlNode *settings); + virtual bool Save(TiXmlNode *settings) const; + + const CVideoSettings& GetDefaultVideoSettings() const { return m_defaultVideoSettings; } + CVideoSettings& GetDefaultVideoSettings() { return m_defaultVideoSettings; } + const CVideoSettings& GetCurrentVideoSettings() const { return m_currentVideoSettings; } + CVideoSettings& GetCurrentVideoSettings() { return m_currentVideoSettings; } + + /*! \brief Retreive the watched mode for the given content type + \param content Current content type + \return the current watch mode for this content type, WATCH_MODE_ALL if the content type is unknown. + \sa SetWatchMode + */ + int GetWatchedMode(const std::string &content) const; + + /*! \brief Set the watched mode for the given content type + \param content Current content type + \param value Watched mode to set + \sa GetWatchMode + */ + void SetWatchedMode(const std::string &content, WatchedMode mode); + + /*! \brief Cycle the watched mode for the given content type + \param content Current content type + \sa GetWatchMode, SetWatchMode + */ + void CycleWatchedMode(const std::string &content); + +protected: + CMediaSettings(); + CMediaSettings(const CMediaSettings&); + CMediaSettings const& operator=(CMediaSettings const&); + virtual ~CMediaSettings(); + + static std::string GetWatchedContent(const std::string &content); + +private: + CVideoSettings m_defaultVideoSettings; + CVideoSettings m_currentVideoSettings; + + typedef std::map<std::string, WatchedMode> WatchedModes; + WatchedModes m_watchedModes; + + CCriticalSection m_critical; +}; diff --git a/xbmc/settings/MediaSourceSettings.cpp b/xbmc/settings/MediaSourceSettings.cpp new file mode 100644 index 0000000000..60c679fa3d --- /dev/null +++ b/xbmc/settings/MediaSourceSettings.cpp @@ -0,0 +1,495 @@ +/* + * 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 "MediaSourceSettings.h" +#include "URL.h" +#include "Util.h" +#include "filesystem/File.h" +#include "settings/Settings.h" +#include "utils/log.h" +#include "utils/StringUtils.h" +#include "utils/URIUtils.h" +#include "utils/XBMCTinyXML.h" +#include "utils/XMLUtils.h" + +#define SOURCES_FILE "sources.xml" +#define XML_SOURCES "sources" +#define XML_SOURCE "source" + +using namespace std; +using namespace XFILE; + +CMediaSourceSettings::CMediaSourceSettings() +{ + Clear(); +} + +CMediaSourceSettings::~CMediaSourceSettings() +{ } + +CMediaSourceSettings& CMediaSourceSettings::Get() +{ + static CMediaSourceSettings sMediaSourceSettings; + return sMediaSourceSettings; +} + +std::string CMediaSourceSettings::GetSourcesFile() +{ + std::string file; + if (g_settings.GetCurrentProfile().hasSources()) + file = g_settings.GetProfileUserDataFolder(); + else + file = g_settings.GetUserDataFolder(); + + return URIUtils::AddFileToFolder(file, SOURCES_FILE); +} + +void CMediaSourceSettings::OnSettingsLoaded() +{ + Load(); +} + +void CMediaSourceSettings::OnSettingsCleared() +{ + Clear(); +} + +bool CMediaSourceSettings::Load() +{ + return Load(GetSourcesFile()); +} + +bool CMediaSourceSettings::Load(const std::string &file) +{ + Clear(); + + if (!CFile::Exists(file)) + return false; + + CLog::Log(LOGNOTICE, "CMediaSourceSettings: loading media sources from %s", file.c_str()); + + // load xml file + CXBMCTinyXML xmlDoc; + if (!xmlDoc.LoadFile(file)) + { + CLog::Log(LOGERROR, "CMediaSourceSettings: error loading %s: Line %d, %s", file.c_str(), xmlDoc.ErrorRow(), xmlDoc.ErrorDesc()); + return false; + } + + TiXmlElement *pRootElement = xmlDoc.RootElement(); + if (pRootElement == NULL || !StringUtils::EqualsNoCase(pRootElement->ValueStr(), XML_SOURCES)) + CLog::Log(LOGERROR, "CMediaSourceSettings: sources.xml file does not contain <sources>"); + + // parse sources + std::string dummy; + GetSources(pRootElement, "video", m_videoSources, dummy); + GetSources(pRootElement, "programs", m_programSources, m_defaultProgramSource); + GetSources(pRootElement, "pictures", m_pictureSources, m_defaultPictureSource); + GetSources(pRootElement, "files", m_fileSources, m_defaultFileSource); + GetSources(pRootElement, "music", m_musicSources, m_defaultMusicSource); + + return true; +} + +bool CMediaSourceSettings::Save() +{ + return Save(GetSourcesFile()); +} + +bool CMediaSourceSettings::Save(const std::string &file) const +{ + if (!CFile::Exists(file)) + return false; + + // TODO: Should we be specifying utf8 here?? + CXBMCTinyXML doc; + TiXmlElement xmlRootElement(XML_SOURCES); + TiXmlNode *pRoot = doc.InsertEndChild(xmlRootElement); + if (pRoot == NULL) + return false; + + // ok, now run through and save each sources section + SetSources(pRoot, "programs", m_programSources, m_defaultProgramSource); + SetSources(pRoot, "video", m_videoSources, ""); + SetSources(pRoot, "music", m_musicSources, m_defaultMusicSource); + SetSources(pRoot, "pictures", m_pictureSources, m_defaultPictureSource); + SetSources(pRoot, "files", m_fileSources, m_defaultFileSource); + + return doc.SaveFile(file); +} + +void CMediaSourceSettings::Clear() +{ + m_programSources.clear(); + m_pictureSources.clear(); + m_fileSources.clear(); + m_musicSources.clear(); + m_videoSources.clear(); +} + +VECSOURCES* CMediaSourceSettings::GetSources(const std::string &type) +{ + if (type == "programs" || type == "myprograms") + return &m_programSources; + else if (type == "files") + return &m_fileSources; + else if (type == "music") + return &m_musicSources; + else if (type == "video" || type == "videos") + return &m_videoSources; + else if (type == "pictures") + return &m_pictureSources; + + return NULL; +} + +const std::string& CMediaSourceSettings::GetDefaultSource(const std::string &type) const +{ + if (type == "programs" || type == "myprograms") + return m_defaultProgramSource; + else if (type == "files") + return m_defaultFileSource; + else if (type == "music") + return m_defaultMusicSource; + else if (type == "pictures") + return m_defaultPictureSource; + + return StringUtils::Empty; +} + +void CMediaSourceSettings::SetDefaultSource(const std::string &type, const std::string &source) +{ + if (type == "programs" || type == "myprograms") + m_defaultProgramSource = source; + else if (type == "files") + m_defaultFileSource = source; + else if (type == "music") + m_defaultMusicSource = source; + else if (type == "pictures") + m_defaultPictureSource = source; +} + +// NOTE: This function does NOT save the sources.xml file - you need to call SaveSources() separately. +bool CMediaSourceSettings::UpdateSource(const std::string &strType, const std::string strOldName, const std::string &strUpdateChild, const std::string &strUpdateValue) +{ + VECSOURCES *pShares = GetSources(strType); + if (pShares == NULL) + return false; + + for (IVECSOURCES it = pShares->begin(); it != pShares->end(); it++) + { + if (it->strName == strOldName) + { + if (strUpdateChild == "name") + it->strName = strUpdateValue; + else if (strUpdateChild == "lockmode") + it->m_iLockMode = (LockType)strtol(strUpdateValue.c_str(), NULL, 10); + else if (strUpdateChild == "lockcode") + it->m_strLockCode = strUpdateValue; + else if (strUpdateChild == "badpwdcount") + it->m_iBadPwdCount = (int)strtol(strUpdateValue.c_str(), NULL, 10); + else if (strUpdateChild == "thumbnail") + it->m_strThumbnailImage = strUpdateValue; + else if (strUpdateChild == "path") + { + it->vecPaths.clear(); + it->strPath = strUpdateValue; + it->vecPaths.push_back(strUpdateValue); + } + else + return false; + + return true; + } + } + + return false; +} + +bool CMediaSourceSettings::DeleteSource(const std::string &strType, const std::string &strName, const std::string strPath, bool virtualSource /* = false */) +{ + VECSOURCES *pShares = GetSources(strType); + if (pShares == NULL) + return false; + + bool found = false; + + for (IVECSOURCES it = pShares->begin(); it != pShares->end(); it++) + { + if (it->strName == strName && it->strPath == strPath) + { + CLog::Log(LOGDEBUG, "CMediaSourceSettings: found share, removing!"); + pShares->erase(it); + found = true; + break; + } + } + + if (virtualSource) + return found; + + return Save(); +} + +bool CMediaSourceSettings::AddShare(const std::string &type, const CMediaSource &share) +{ + VECSOURCES *pShares = GetSources(type); + if (pShares == NULL) + return false; + + // translate dir and add to our current shares + string strPath1 = share.strPath; + if (strPath1.empty()) + { + CLog::Log(LOGERROR, "CMediaSourceSettings: unable to add empty path"); + return false; + } + StringUtils::ToUpper(strPath1); + + CMediaSource shareToAdd = share; + if (strPath1.at(0) == '$') + { + shareToAdd.strPath = CUtil::TranslateSpecialSource(strPath1); + if (!share.strPath.empty()) + CLog::Log(LOGDEBUG, "CMediaSourceSettings: translated (%s) to path (%s)", strPath1.c_str(), shareToAdd.strPath.c_str()); + else + { + CLog::Log(LOGDEBUG, "CMediaSourceSettings: skipping invalid special directory token (%s)", strPath1.c_str()); + return false; + } + } + pShares->push_back(shareToAdd); + + if (!share.m_ignore) + return Save(); + + return true; +} + +bool CMediaSourceSettings::UpdateShare(const std::string &type, const std::string &oldName, const CMediaSource &share) +{ + VECSOURCES *pShares = GetSources(type); + if (pShares == NULL) + return false; + + // update our current share list + CMediaSource* pShare = NULL; + for (IVECSOURCES it = pShares->begin(); it != pShares->end(); it++) + { + if (it->strName == oldName) + { + it->strName = share.strName; + it->strPath = share.strPath; + it->vecPaths = share.vecPaths; + pShare = &(*it); + break; + } + } + + if (pShare == NULL) + return false; + + // Update our XML file as well + return Save(); +} + +bool CMediaSourceSettings::GetSource(const std::string &category, const TiXmlNode *source, CMediaSource &share) +{ + const TiXmlNode *pNodeName = source->FirstChild("name"); + string strName; + if (pNodeName && pNodeName->FirstChild()) + strName = pNodeName->FirstChild()->ValueStr(); + + // get multiple paths + vector<string> vecPaths; + const TiXmlElement *pPathName = source->FirstChildElement("path"); + while (pPathName != NULL) + { + if (pPathName->FirstChild()) + { + CStdString strPath = pPathName->FirstChild()->ValueStr(); + + // make sure there are no virtualpaths or stack paths defined in xboxmediacenter.xml + if (!URIUtils::IsStack(strPath)) + { + // translate special tags + if (!strPath.empty() && strPath.at(0) == '$') + { + string strPathOld(strPath); + strPath = CUtil::TranslateSpecialSource(strPath); + } + + // need to check path validity again as CUtil::TranslateSpecialSource() may have failed + if (!strPath.empty()) + { + URIUtils::AddSlashAtEnd(strPath); + vecPaths.push_back(strPath); + } + } + else + CLog::Log(LOGERROR, "CMediaSourceSettings: invalid path type (%s) in source", strPath.c_str()); + } + + pPathName = pPathName->NextSiblingElement("path"); + } + + const TiXmlNode *pLockMode = source->FirstChild("lockmode"); + const TiXmlNode *pLockCode = source->FirstChild("lockcode"); + const TiXmlNode *pBadPwdCount = source->FirstChild("badpwdcount"); + const TiXmlNode *pThumbnailNode = source->FirstChild("thumbnail"); + + if (strName.empty() || vecPaths.empty()) + return false; + + vector<CStdString> verifiedPaths; + // disallowed for files, or theres only a single path in the vector + if (StringUtils::EqualsNoCase(category, "files") || vecPaths.size() == 1) + verifiedPaths.push_back(vecPaths[0]); + // multiple paths? + else + { + // validate the paths + for (vector<string>::const_iterator path = vecPaths.begin(); path != vecPaths.end(); path++) + { + CURL url(*path); + string protocol = url.GetProtocol(); + bool bIsInvalid = false; + + // for my programs + if (StringUtils::EqualsNoCase(category, "programs") || StringUtils::EqualsNoCase(category, "myprograms")) + { + // only allow HD and plugins + if (url.IsLocal() || StringUtils::EqualsNoCase(protocol, "plugin")) + verifiedPaths.push_back(*path); + else + bIsInvalid = true; + } + // for others allow everything (if the user does something silly, we can't stop them) + else + verifiedPaths.push_back(*path); + + // error message + if (bIsInvalid) + CLog::Log(LOGERROR,"CMediaSourceSettings: invalid path type (%s) for multipath source", path->c_str()); + } + + // no valid paths? skip to next source + if (verifiedPaths.empty()) + { + CLog::Log(LOGERROR,"CMediaSourceSettings: missing or invalid <name> and/or <path> in source"); + return false; + } + } + + share.FromNameAndPaths(category, strName, verifiedPaths); + + share.m_iBadPwdCount = 0; + if (pLockMode) + { + share.m_iLockMode = (LockType)strtol(pLockMode->FirstChild()->Value(), NULL, 10); + share.m_iHasLock = 2; + } + + if (pLockCode && pLockCode->FirstChild()) + share.m_strLockCode = pLockCode->FirstChild()->Value(); + + if (pBadPwdCount && pBadPwdCount->FirstChild()) + share.m_iBadPwdCount = (int)strtol(pBadPwdCount->FirstChild()->Value(), NULL, 10); + + if (pThumbnailNode && pThumbnailNode->FirstChild()) + share.m_strThumbnailImage = pThumbnailNode->FirstChild()->Value(); + + return true; +} + +void CMediaSourceSettings::GetSources(const TiXmlNode* pRootElement, const std::string& strTagName, VECSOURCES& items, std::string& strDefault) +{ + strDefault = ""; + items.clear(); + + const TiXmlNode *pChild = pRootElement->FirstChild(strTagName.c_str()); + if (pChild == NULL) + { + CLog::Log(LOGDEBUG, "CMediaSourceSettings: <%s> tag is missing or sources.xml is malformed", strTagName.c_str()); + return; + } + + pChild = pChild->FirstChild(); + while (pChild != NULL) + { + std::string strValue = pChild->ValueStr(); + if (strValue == XML_SOURCE || strValue == "bookmark") // "bookmark" left in for backwards compatibility + { + CMediaSource share; + if (GetSource(strTagName, pChild, share)) + items.push_back(share); + else + CLog::Log(LOGERROR, "CMediaSourceSettings: Missing or invalid <name> and/or <path> in source"); + } + else if (strValue == "default") + { + const TiXmlNode *pValueNode = pChild->FirstChild(); + if (pValueNode) + { + std::string pszText = pChild->FirstChild()->ValueStr(); + if (!pszText.empty()) + strDefault = pszText; + CLog::Log(LOGDEBUG, "CMediaSourceSettings: Setting <default> source to : %s", strDefault.c_str()); + } + } + + pChild = pChild->NextSibling(); + } +} + +bool CMediaSourceSettings::SetSources(TiXmlNode *root, const char *section, const VECSOURCES &shares, const std::string &defaultPath) const +{ + TiXmlElement sectionElement(section); + TiXmlNode *sectionNode = root->InsertEndChild(sectionElement); + if (sectionNode == NULL) + return false; + + XMLUtils::SetPath(sectionNode, "default", defaultPath); + for (CIVECSOURCES it = shares.begin(); it != shares.end(); it++) + { + const CMediaSource &share = *it; + if (share.m_ignore) + continue; + + TiXmlElement source(XML_SOURCE); + XMLUtils::SetString(&source, "name", share.strName); + + for (unsigned int i = 0; i < share.vecPaths.size(); i++) + XMLUtils::SetPath(&source, "path", share.vecPaths[i]); + + if (share.m_iHasLock) + { + XMLUtils::SetInt(&source, "lockmode", share.m_iLockMode); + XMLUtils::SetString(&source, "lockcode", share.m_strLockCode); + XMLUtils::SetInt(&source, "badpwdcount", share.m_iBadPwdCount); + } + if (!share.m_strThumbnailImage.empty()) + XMLUtils::SetPath(&source, "thumbnail", share.m_strThumbnailImage); + + sectionNode->InsertEndChild(source); + } + + return true; +} diff --git a/xbmc/settings/MediaSourceSettings.h b/xbmc/settings/MediaSourceSettings.h new file mode 100644 index 0000000000..0602f80383 --- /dev/null +++ b/xbmc/settings/MediaSourceSettings.h @@ -0,0 +1,75 @@ +#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 <string> + +#include "MediaSource.h" +#include "settings/ISettingsHandler.h" + +class TiXmlNode; + +class CMediaSourceSettings : public ISettingsHandler +{ +public: + static CMediaSourceSettings& Get(); + + static std::string GetSourcesFile(); + + virtual void OnSettingsLoaded(); + virtual void OnSettingsCleared(); + + bool Load(); + bool Load(const std::string &file); + bool Save(); + bool Save(const std::string &file) const; + void Clear(); + + VECSOURCES* GetSources(const std::string &type); + const std::string& GetDefaultSource(const std::string &type) const; + void SetDefaultSource(const std::string &type, const std::string &source); + + bool UpdateSource(const std::string &strType, const std::string strOldName, const std::string &strUpdateChild, const std::string &strUpdateValue); + bool DeleteSource(const std::string &strType, const std::string &strName, const std::string strPath, bool virtualSource = false); + bool AddShare(const std::string &type, const CMediaSource &share); + bool UpdateShare(const std::string &type, const std::string &oldName, const CMediaSource &share); + +protected: + CMediaSourceSettings(); + CMediaSourceSettings(const CMediaSourceSettings&); + CMediaSourceSettings const& operator=(CMediaSourceSettings const&); + virtual ~CMediaSourceSettings(); + +private: + bool GetSource(const std::string &category, const TiXmlNode *source, CMediaSource &share); + void GetSources(const TiXmlNode* pRootElement, const std::string& strTagName, VECSOURCES& items, std::string& strDefault); + bool SetSources(TiXmlNode *root, const char *section, const VECSOURCES &shares, const std::string &defaultPath) const; + + VECSOURCES m_programSources; + VECSOURCES m_pictureSources; + VECSOURCES m_fileSources; + VECSOURCES m_musicSources; + VECSOURCES m_videoSources; + + std::string m_defaultProgramSource; + std::string m_defaultMusicSource; + std::string m_defaultPictureSource; + std::string m_defaultFileSource; +}; diff --git a/xbmc/settings/Settings.cpp b/xbmc/settings/Settings.cpp index 3bb10695da..8f18e00169 100644 --- a/xbmc/settings/Settings.cpp +++ b/xbmc/settings/Settings.cpp @@ -49,16 +49,13 @@ #if defined(_LINUX) && defined(HAS_FILESYSTEM_SMB) #include "filesystem/SMBDirectory.h" #endif -#include "cores/playercorefactory/PlayerCoreFactory.h" #include "utils/FileUtils.h" #include "utils/URIUtils.h" #include "input/MouseStat.h" #include "filesystem/File.h" #include "filesystem/DirectoryCache.h" #include "DatabaseManager.h" -#ifdef HAS_UPNP -#include "network/upnp/UPnPSettings.h" -#endif +#include "threads/SingleLock.h" #include "utils/RssManager.h" using namespace std; @@ -68,6 +65,42 @@ CSettings::CSettings(void) { } +void CSettings::RegisterSettingsHandler(ISettingsHandler *settingsHandler) +{ + if (settingsHandler == NULL) + return; + + CSingleLock lock(m_critical); + m_settingsHandlers.insert(settingsHandler); +} + +void CSettings::UnregisterSettingsHandler(ISettingsHandler *settingsHandler) +{ + if (settingsHandler == NULL) + return; + + CSingleLock lock(m_critical); + m_settingsHandlers.erase(settingsHandler); +} + +void CSettings::RegisterSubSettings(ISubSettings *subSettings) +{ + if (subSettings == NULL) + return; + + CSingleLock lock(m_critical); + m_subSettings.insert(subSettings); +} + +void CSettings::UnregisterSubSettings(ISubSettings *subSettings) +{ + if (subSettings == NULL) + return; + + CSingleLock lock(m_critical); + m_subSettings.erase(subSettings); +} + void CSettings::Initialize() { RESOLUTION_INFO res; @@ -124,10 +157,6 @@ void CSettings::Initialize() m_iMyMusicStartWindow = WINDOW_MUSIC_FILES; m_iVideoStartWindow = WINDOW_VIDEO_FILES; - m_watchMode["movies"] = VIDEO_SHOW_ALL; - m_watchMode["tvshows"] = VIDEO_SHOW_ALL; - m_watchMode["musicvideos"] = VIDEO_SHOW_ALL; - m_iSystemTimeTotalUp = 0; m_userAgent = g_sysinfo.GetUserAgent(); @@ -142,22 +171,20 @@ void CSettings::Initialize() } CSettings::~CSettings(void) -{ } +{ + // first clear all registered settings handler and subsettings + // implementations because we can't be sure that they are still valid + m_settingsHandlers.clear(); + m_subSettings.clear(); + + Clear(); +} void CSettings::Save() const { - if (g_application.m_bStop) - { - //don't save settings when we're busy stopping the application - //a lot of screens try to save settings on deinit and deinit is called - //for every screen when the application is stopping. - return ; - } if (!SaveSettings(GetSettingsFile())) - { CLog::Log(LOGERROR, "Unable to save settings to %s", GetSettingsFile().c_str()); - } } bool CSettings::Reset() @@ -170,6 +197,9 @@ bool CSettings::Reset() bool CSettings::Load() { + if (!OnSettingsLoading()) + return false; + CSpecialProtocol::SetProfilePath(GetProfileUserDataFolder()); CLog::Log(LOGNOTICE, "loading %s", GetSettingsFile().c_str()); if (!LoadSettings(GetSettingsFile())) @@ -179,215 +209,11 @@ bool CSettings::Load() return false; } - LoadSources(); - CRssManager::Get().Load(); LoadUserFolderLayout(); - return true; -} - -VECSOURCES *CSettings::GetSourcesFromType(const CStdString &type) -{ - if (type == "programs" || type == "myprograms") - return &m_programSources; - else if (type == "files") - return &m_fileSources; - else if (type == "music") - return &m_musicSources; - else if (type == "video") - return &m_videoSources; - else if (type == "pictures") - return &m_pictureSources; - - return NULL; -} - -CStdString CSettings::GetDefaultSourceFromType(const CStdString &type) -{ - CStdString defaultShare; - if (type == "programs" || type == "myprograms") - defaultShare = m_defaultProgramSource; - else if (type == "files") - defaultShare = m_defaultFileSource; - else if (type == "music") - defaultShare = m_defaultMusicSource; - else if (type == "pictures") - defaultShare = m_defaultPictureSource; - return defaultShare; -} - -void CSettings::GetSources(const TiXmlElement* pRootElement, const CStdString& strTagName, VECSOURCES& items, CStdString& strDefault) -{ - //CLog::Log(LOGDEBUG, " Parsing <%s> tag", strTagName.c_str()); - strDefault = ""; - - items.clear(); - const TiXmlNode *pChild = pRootElement->FirstChild(strTagName.c_str()); - if (pChild) - { - pChild = pChild->FirstChild(); - while (pChild > 0) - { - CStdString strValue = pChild->Value(); - if (strValue == "source" || strValue == "bookmark") // "bookmark" left in for backwards compatibility - { - CMediaSource share; - if (GetSource(strTagName, pChild, share)) - { - items.push_back(share); - } - else - { - CLog::Log(LOGERROR, " Missing or invalid <name> and/or <path> in source"); - } - } - - if (strValue == "default") - { - const TiXmlNode *pValueNode = pChild->FirstChild(); - if (pValueNode) - { - const char* pszText = pChild->FirstChild()->Value(); - if (strlen(pszText) > 0) - strDefault = pszText; - CLog::Log(LOGDEBUG, " Setting <default> source to : %s", strDefault.c_str()); - } - } - pChild = pChild->NextSibling(); - } - } - else - { - CLog::Log(LOGDEBUG, " <%s> tag is missing or sources.xml is malformed", strTagName.c_str()); - } -} - -bool CSettings::GetSource(const CStdString &category, const TiXmlNode *source, CMediaSource &share) -{ - //CLog::Log(LOGDEBUG," ---- SOURCE START ----"); - const TiXmlNode *pNodeName = source->FirstChild("name"); - CStdString strName; - if (pNodeName && pNodeName->FirstChild()) - { - strName = pNodeName->FirstChild()->Value(); - //CLog::Log(LOGDEBUG," Found name: %s", strName.c_str()); - } - // get multiple paths - vector<CStdString> vecPaths; - const TiXmlElement *pPathName = source->FirstChildElement("path"); - while (pPathName) - { - if (pPathName->FirstChild()) - { - CStdString strPath = pPathName->FirstChild()->Value(); - // make sure there are no virtualpaths or stack paths defined in xboxmediacenter.xml - //CLog::Log(LOGDEBUG," Found path: %s", strPath.c_str()); - if (!URIUtils::IsStack(strPath)) - { - // translate special tags - if (!strPath.IsEmpty() && strPath.at(0) == '$') - { - CStdString strPathOld(strPath); - strPath = CUtil::TranslateSpecialSource(strPath); - if (!strPath.IsEmpty()) - { - //CLog::Log(LOGDEBUG," -> Translated to path: %s", strPath.c_str()); - } - else - { - //CLog::Log(LOGERROR," -> Skipping invalid token: %s", strPathOld.c_str()); - pPathName = pPathName->NextSiblingElement("path"); - continue; - } - } - URIUtils::AddSlashAtEnd(strPath); - vecPaths.push_back(strPath); - } - else - CLog::Log(LOGERROR," Invalid path type (%s) in source", strPath.c_str()); - } - pPathName = pPathName->NextSiblingElement("path"); - } - - const TiXmlNode *pLockMode = source->FirstChild("lockmode"); - const TiXmlNode *pLockCode = source->FirstChild("lockcode"); - const TiXmlNode *pBadPwdCount = source->FirstChild("badpwdcount"); - const TiXmlNode *pThumbnailNode = source->FirstChild("thumbnail"); - - if (!strName.IsEmpty() && vecPaths.size() > 0) - { - vector<CStdString> verifiedPaths; - // disallowed for files, or theres only a single path in the vector - if ((category.Equals("files")) || (vecPaths.size() == 1)) - verifiedPaths.push_back(vecPaths[0]); - - // multiple paths? - else - { - // validate the paths - for (int j = 0; j < (int)vecPaths.size(); ++j) - { - CURL url(vecPaths[j]); - CStdString protocol = url.GetProtocol(); - bool bIsInvalid = false; - - // for my programs - if (category.Equals("programs") || category.Equals("myprograms")) - { - // only allow HD and plugins - if (url.IsLocal() || protocol.Equals("plugin")) - verifiedPaths.push_back(vecPaths[j]); - else - bIsInvalid = true; - } - - // for others allow everything (if the user does something silly, we can't stop them) - else - verifiedPaths.push_back(vecPaths[j]); - - // error message - if (bIsInvalid) - CLog::Log(LOGERROR," Invalid path type (%s) for multipath source", vecPaths[j].c_str()); - } - - // no valid paths? skip to next source - if (verifiedPaths.size() == 0) - { - CLog::Log(LOGERROR," Missing or invalid <name> and/or <path> in source"); - return false; - } - } - - share.FromNameAndPaths(category, strName, verifiedPaths); - - share.m_iBadPwdCount = 0; - if (pLockMode) - { - share.m_iLockMode = LockType(atoi(pLockMode->FirstChild()->Value())); - share.m_iHasLock = 2; - } - - if (pLockCode) - { - if (pLockCode->FirstChild()) - share.m_strLockCode = pLockCode->FirstChild()->Value(); - } - - if (pBadPwdCount) - { - if (pBadPwdCount->FirstChild()) - share.m_iBadPwdCount = atoi( pBadPwdCount->FirstChild()->Value() ); - } - - if (pThumbnailNode) - { - if (pThumbnailNode->FirstChild()) - share.m_strThumbnailImage = pThumbnailNode->FirstChild()->Value(); - } + OnSettingsLoaded(); - return true; - } - return false; + return true; } bool CSettings::GetPath(const TiXmlElement* pRootElement, const char *tagName, CStdString &strValue) @@ -444,38 +270,6 @@ bool CSettings::GetFloat(const TiXmlElement* pRootElement, const char *tagName, return false; } -void CSettings::GetViewState(const TiXmlElement *pRootElement, const CStdString &strTagName, CViewState &viewState, SORT_METHOD defaultSort, int defaultView) -{ - const TiXmlElement* pNode = pRootElement->FirstChildElement(strTagName); - if (!pNode) - { - viewState.m_sortMethod = defaultSort; - viewState.m_viewMode = defaultView; - return; - } - GetInteger(pNode, "viewmode", viewState.m_viewMode, defaultView, DEFAULT_VIEW_LIST, DEFAULT_VIEW_MAX); - - int sortMethod; - GetInteger(pNode, "sortmethod", sortMethod, defaultSort, SORT_METHOD_NONE, SORT_METHOD_MAX); - viewState.m_sortMethod = (SORT_METHOD)sortMethod; - - int sortOrder; - GetInteger(pNode, "sortorder", sortOrder, SortOrderAscending, SortOrderNone, SortOrderDescending); - viewState.m_sortOrder = (SortOrder)sortOrder; -} - -void CSettings::SetViewState(TiXmlNode *pRootNode, const CStdString &strTagName, const CViewState &viewState) const -{ - TiXmlElement newElement(strTagName); - TiXmlNode *pNewNode = pRootNode->InsertEndChild(newElement); - if (pNewNode) - { - XMLUtils::SetInt(pNewNode, "viewmode", viewState.m_viewMode); - XMLUtils::SetInt(pNewNode, "sortmethod", (int)viewState.m_sortMethod); - XMLUtils::SetInt(pNewNode, "sortorder", (int)viewState.m_sortOrder); - } -} - bool CSettings::LoadCalibration(const TiXmlElement* pRoot, const CStdString& strSettingsFile) { m_Calibrations.clear(); @@ -674,18 +468,13 @@ bool CSettings::LoadSettings(const CStdString& strSettingsFile) GetInteger(pElement, "needsupdate", m_musicNeedsUpdate, 0, 0, INT_MAX); GetPath(pElement, "defaultlibview", m_defaultMusicLibSource); } + // myvideos settings pElement = pRootElement->FirstChildElement("myvideos"); if (pElement) { GetInteger(pElement, "startwindow", m_iVideoStartWindow, WINDOW_VIDEO_FILES, WINDOW_VIDEO_FILES, WINDOW_VIDEO_NAV); XMLUtils::GetBoolean(pElement, "stackvideos", m_videoStacking); - - // Read the watchmode settings for the various media views - GetInteger(pElement, "watchmodemovies", m_watchMode["movies"], VIDEO_SHOW_ALL, VIDEO_SHOW_ALL, VIDEO_SHOW_WATCHED); - GetInteger(pElement, "watchmodetvshows", m_watchMode["tvshows"], VIDEO_SHOW_ALL, VIDEO_SHOW_ALL, VIDEO_SHOW_WATCHED); - GetInteger(pElement, "watchmodemusicvideos", m_watchMode["musicvideos"], VIDEO_SHOW_ALL, VIDEO_SHOW_ALL, VIDEO_SHOW_WATCHED); - XMLUtils::GetBoolean(pElement, "flatten", m_bMyVideoNavFlatten); GetInteger(pElement, "needsupdate", m_videoNeedsUpdate, 0, 0, INT_MAX); @@ -697,27 +486,6 @@ bool CSettings::LoadSettings(const CStdString& strSettingsFile) } } - pElement = pRootElement->FirstChildElement("viewstates"); - if (pElement) - { - GetViewState(pElement, "musicnavartists", m_viewStateMusicNavArtists); - GetViewState(pElement, "musicnavalbums", m_viewStateMusicNavAlbums); - GetViewState(pElement, "musicnavsongs", m_viewStateMusicNavSongs); - GetViewState(pElement, "videonavactors", m_viewStateVideoNavActors); - GetViewState(pElement, "videonavyears", m_viewStateVideoNavYears); - GetViewState(pElement, "videonavgenres", m_viewStateVideoNavGenres); - GetViewState(pElement, "videonavtitles", m_viewStateVideoNavTitles); - GetViewState(pElement, "videonavepisodes", m_viewStateVideoNavEpisodes, SORT_METHOD_EPISODE); - GetViewState(pElement, "videonavtvshows", m_viewStateVideoNavTvShows); - GetViewState(pElement, "videonavseasons", m_viewStateVideoNavSeasons); - GetViewState(pElement, "videonavmusicvideos", m_viewStateVideoNavMusicVideos); - - GetViewState(pElement, "programs", m_viewStatePrograms, SORT_METHOD_LABEL, DEFAULT_VIEW_AUTO); - GetViewState(pElement, "pictures", m_viewStatePictures, SORT_METHOD_LABEL, DEFAULT_VIEW_AUTO); - GetViewState(pElement, "videofiles", m_viewStateVideoFiles, SORT_METHOD_LABEL, DEFAULT_VIEW_AUTO); - GetViewState(pElement, "musicfiles", m_viewStateMusicFiles, SORT_METHOD_LABEL, DEFAULT_VIEW_AUTO); - } - // general settings pElement = pRootElement->FirstChildElement("general"); if (pElement) @@ -728,56 +496,6 @@ bool CSettings::LoadSettings(const CStdString& strSettingsFile) XMLUtils::GetBoolean(pElement, "addonforeignfilter", m_bAddonForeignFilter); } - pElement = pRootElement->FirstChildElement("defaultvideosettings"); - if (pElement) - { - int deinterlaceMode; - bool deinterlaceModePresent = GetInteger(pElement, "deinterlacemode", deinterlaceMode, VS_DEINTERLACEMODE_OFF, VS_DEINTERLACEMODE_OFF, VS_DEINTERLACEMODE_FORCE); - int interlaceMethod; - bool interlaceMethodPresent = GetInteger(pElement, "interlacemethod", interlaceMethod, VS_INTERLACEMETHOD_AUTO, VS_INTERLACEMETHOD_AUTO, VS_INTERLACEMETHOD_MAX); - // For smooth conversion of settings stored before the deinterlaceMode existed - if (!deinterlaceModePresent && interlaceMethodPresent) - { - if (interlaceMethod == VS_INTERLACEMETHOD_NONE) - { - deinterlaceMode = VS_DEINTERLACEMODE_OFF; - interlaceMethod = VS_INTERLACEMETHOD_AUTO; - } - else if (interlaceMethod == VS_INTERLACEMETHOD_AUTO) - { - deinterlaceMode = VS_DEINTERLACEMODE_AUTO; - } - else - { - deinterlaceMode = VS_DEINTERLACEMODE_FORCE; - } - } - m_defaultVideoSettings.m_DeinterlaceMode = (EDEINTERLACEMODE)deinterlaceMode; - m_defaultVideoSettings.m_InterlaceMethod = (EINTERLACEMETHOD)interlaceMethod; - int scalingMethod; - GetInteger(pElement, "scalingmethod", scalingMethod, VS_SCALINGMETHOD_LINEAR, VS_SCALINGMETHOD_NEAREST, VS_SCALINGMETHOD_MAX); - m_defaultVideoSettings.m_ScalingMethod = (ESCALINGMETHOD)scalingMethod; - - GetInteger(pElement, "viewmode", m_defaultVideoSettings.m_ViewMode, VIEW_MODE_NORMAL, VIEW_MODE_NORMAL, VIEW_MODE_CUSTOM); - GetFloat(pElement, "zoomamount", m_defaultVideoSettings.m_CustomZoomAmount, 1.0f, 0.5f, 2.0f); - GetFloat(pElement, "pixelratio", m_defaultVideoSettings.m_CustomPixelRatio, 1.0f, 0.5f, 2.0f); - GetFloat(pElement, "verticalshift", m_defaultVideoSettings.m_CustomVerticalShift, 0.0f, -2.0f, 2.0f); - GetFloat(pElement, "volumeamplification", m_defaultVideoSettings.m_VolumeAmplification, VOLUME_DRC_MINIMUM * 0.01f, VOLUME_DRC_MINIMUM * 0.01f, VOLUME_DRC_MAXIMUM * 0.01f); - GetFloat(pElement, "noisereduction", m_defaultVideoSettings.m_NoiseReduction, 0.0f, 0.0f, 1.0f); - XMLUtils::GetBoolean(pElement, "postprocess", m_defaultVideoSettings.m_PostProcess); - GetFloat(pElement, "sharpness", m_defaultVideoSettings.m_Sharpness, 0.0f, -1.0f, 1.0f); - XMLUtils::GetBoolean(pElement, "outputtoallspeakers", m_defaultVideoSettings.m_OutputToAllSpeakers); - XMLUtils::GetBoolean(pElement, "showsubtitles", m_defaultVideoSettings.m_SubtitleOn); - GetFloat(pElement, "brightness", m_defaultVideoSettings.m_Brightness, 50, 0, 100); - GetFloat(pElement, "contrast", m_defaultVideoSettings.m_Contrast, 50, 0, 100); - GetFloat(pElement, "gamma", m_defaultVideoSettings.m_Gamma, 20, 0, 100); - GetFloat(pElement, "audiodelay", m_defaultVideoSettings.m_AudioDelay, 0.0f, -10.0f, 10.0f); - GetFloat(pElement, "subtitledelay", m_defaultVideoSettings.m_SubtitleDelay, 0.0f, -10.0f, 10.0f); - XMLUtils::GetBoolean(pElement, "autocrop", m_defaultVideoSettings.m_Crop); - XMLUtils::GetBoolean(pElement, "nonlinstretch", m_defaultVideoSettings.m_CustomNonLinStretch); - - m_defaultVideoSettings.m_SubtitleCached = false; - } // audio settings pElement = pRootElement->FirstChildElement("audio"); if (pElement) @@ -788,37 +506,9 @@ bool CSettings::LoadSettings(const CStdString& strSettingsFile) LoadCalibration(pRootElement, strSettingsFile); g_guiSettings.LoadXML(pRootElement); - LoadSkinSettings(pRootElement); - - // Configure the PlayerCoreFactory - CPlayerCoreFactory::Get().LoadConfiguration("special://xbmc/system/playercorefactory.xml", true); - CPlayerCoreFactory::Get().LoadConfiguration(GetUserDataItem("playercorefactory.xml"), false); - - // Advanced settings - g_advancedSettings.Load(); - - // Add the list of disc stub extensions (if any) to the list of video extensions - if (!m_discStubExtensions.IsEmpty()) - g_settings.m_videoExtensions += "|" + m_discStubExtensions; - - // Default players? - CLog::Log(LOGNOTICE, "Default DVD Player: %s", g_advancedSettings.m_videoDefaultDVDPlayer.c_str()); - CLog::Log(LOGNOTICE, "Default Video Player: %s", g_advancedSettings.m_videoDefaultPlayer.c_str()); - CLog::Log(LOGNOTICE, "Default Audio Player: %s", g_advancedSettings.m_audioDefaultPlayer.c_str()); - - // setup any logging... - if (g_guiSettings.GetBool("debug.showloginfo")) - { - g_advancedSettings.m_logLevel = std::max(g_advancedSettings.m_logLevelHint, LOG_LEVEL_DEBUG_FREEMEM); - CLog::Log(LOGNOTICE, "Enabled debug logging due to GUI setting (%d)", g_advancedSettings.m_logLevel); - } - else - { - g_advancedSettings.m_logLevel = std::min(g_advancedSettings.m_logLevelHint, LOG_LEVEL_DEBUG/*LOG_LEVEL_NORMAL*/); - CLog::Log(LOGNOTICE, "Disabled debug logging due to GUI setting. Level %d.", g_advancedSettings.m_logLevel); - } - CLog::SetLogLevel(g_advancedSettings.m_logLevel); - return true; + + // load any ISubSettings implementations + return Load(pRootElement); } bool CSettings::SaveSettings(const CStdString& strSettingsFile, CGUISettings *localSettings /* = NULL */) const @@ -829,6 +519,9 @@ bool CSettings::SaveSettings(const CStdString& strSettingsFile, CGUISettings *lo if (!pRoot) return false; // write our tags one by one - just a big list for now (can be flashed up later) + if (!OnSettingsSaving()) + return false; + // mymusic settings TiXmlElement musicNode("mymusic"); TiXmlNode *pNode = pRoot->InsertEndChild(musicNode); @@ -855,10 +548,6 @@ bool CSettings::SaveSettings(const CStdString& strSettingsFile, CGUISettings *lo XMLUtils::SetInt(pNode, "startwindow", m_iVideoStartWindow); XMLUtils::SetBoolean(pNode, "stackvideos", m_videoStacking); - - XMLUtils::SetInt(pNode, "watchmodemovies", m_watchMode.find("movies")->second); - XMLUtils::SetInt(pNode, "watchmodetvshows", m_watchMode.find("tvshows")->second); - XMLUtils::SetInt(pNode, "watchmodemusicvideos", m_watchMode.find("musicvideos")->second); XMLUtils::SetInt(pNode, "needsupdate", m_videoNeedsUpdate); XMLUtils::SetBoolean(pNode, "flatten", m_bMyVideoNavFlatten); @@ -870,29 +559,6 @@ bool CSettings::SaveSettings(const CStdString& strSettingsFile, CGUISettings *lo XMLUtils::SetBoolean(pChild, "shuffle", m_bMyVideoPlaylistShuffle); } - // view states - TiXmlElement viewStateNode("viewstates"); - pNode = pRoot->InsertEndChild(viewStateNode); - if (pNode) - { - SetViewState(pNode, "musicnavartists", m_viewStateMusicNavArtists); - SetViewState(pNode, "musicnavalbums", m_viewStateMusicNavAlbums); - SetViewState(pNode, "musicnavsongs", m_viewStateMusicNavSongs); - SetViewState(pNode, "videonavactors", m_viewStateVideoNavActors); - SetViewState(pNode, "videonavyears", m_viewStateVideoNavYears); - SetViewState(pNode, "videonavgenres", m_viewStateVideoNavGenres); - SetViewState(pNode, "videonavtitles", m_viewStateVideoNavTitles); - SetViewState(pNode, "videonavepisodes", m_viewStateVideoNavEpisodes); - SetViewState(pNode, "videonavseasons", m_viewStateVideoNavSeasons); - SetViewState(pNode, "videonavtvshows", m_viewStateVideoNavTvShows); - SetViewState(pNode, "videonavmusicvideos", m_viewStateVideoNavMusicVideos); - - SetViewState(pNode, "programs", m_viewStatePrograms); - SetViewState(pNode, "pictures", m_viewStatePictures); - SetViewState(pNode, "videofiles", m_viewStateVideoFiles); - SetViewState(pNode, "musicfiles", m_viewStateMusicFiles); - } - // general settings TiXmlElement generalNode("general"); pNode = pRoot->InsertEndChild(generalNode); @@ -902,32 +568,6 @@ bool CSettings::SaveSettings(const CStdString& strSettingsFile, CGUISettings *lo XMLUtils::SetBoolean(pNode, "addonnotifications", m_bAddonNotifications); XMLUtils::SetBoolean(pNode, "addonforeignfilter", m_bAddonForeignFilter); - // default video settings - TiXmlElement videoSettingsNode("defaultvideosettings"); - pNode = pRoot->InsertEndChild(videoSettingsNode); - if (!pNode) return false; - XMLUtils::SetInt(pNode, "deinterlacemode", m_defaultVideoSettings.m_DeinterlaceMode); - XMLUtils::SetInt(pNode, "interlacemethod", m_defaultVideoSettings.m_InterlaceMethod); - XMLUtils::SetInt(pNode, "scalingmethod", m_defaultVideoSettings.m_ScalingMethod); - XMLUtils::SetFloat(pNode, "noisereduction", m_defaultVideoSettings.m_NoiseReduction); - XMLUtils::SetBoolean(pNode, "postprocess", m_defaultVideoSettings.m_PostProcess); - XMLUtils::SetFloat(pNode, "sharpness", m_defaultVideoSettings.m_Sharpness); - XMLUtils::SetInt(pNode, "viewmode", m_defaultVideoSettings.m_ViewMode); - XMLUtils::SetFloat(pNode, "zoomamount", m_defaultVideoSettings.m_CustomZoomAmount); - XMLUtils::SetFloat(pNode, "pixelratio", m_defaultVideoSettings.m_CustomPixelRatio); - XMLUtils::SetFloat(pNode, "verticalshift", m_defaultVideoSettings.m_CustomVerticalShift); - XMLUtils::SetFloat(pNode, "volumeamplification", m_defaultVideoSettings.m_VolumeAmplification); - XMLUtils::SetBoolean(pNode, "outputtoallspeakers", m_defaultVideoSettings.m_OutputToAllSpeakers); - XMLUtils::SetBoolean(pNode, "showsubtitles", m_defaultVideoSettings.m_SubtitleOn); - XMLUtils::SetFloat(pNode, "brightness", m_defaultVideoSettings.m_Brightness); - XMLUtils::SetFloat(pNode, "contrast", m_defaultVideoSettings.m_Contrast); - XMLUtils::SetFloat(pNode, "gamma", m_defaultVideoSettings.m_Gamma); - XMLUtils::SetFloat(pNode, "audiodelay", m_defaultVideoSettings.m_AudioDelay); - XMLUtils::SetFloat(pNode, "subtitledelay", m_defaultVideoSettings.m_SubtitleDelay); - XMLUtils::SetBoolean(pNode, "autocrop", m_defaultVideoSettings.m_Crop); - XMLUtils::SetBoolean(pNode, "nonlinstretch", m_defaultVideoSettings.m_CustomNonLinStretch); - - // audio settings TiXmlElement volumeNode("audio"); pNode = pRoot->InsertEndChild(volumeNode); @@ -942,11 +582,14 @@ bool CSettings::SaveSettings(const CStdString& strSettingsFile, CGUISettings *lo else // save the global settings g_guiSettings.SaveXML(pRoot); - SaveSkinSettings(pRoot); - // For mastercode SaveProfiles( PROFILES_FILE ); + OnSettingsSaved(); + + if (!Save(pRoot)) + return false; + // save the file return xmlDoc.SaveFile(strSettingsFile); } @@ -1131,274 +774,6 @@ bool CSettings::SaveProfiles(const CStdString& profilesFile) const return xmlDoc.SaveFile(profilesFile); } -bool CSettings::UpdateShare(const CStdString &type, const CStdString oldName, const CMediaSource &share) -{ - VECSOURCES *pShares = GetSourcesFromType(type); - - if (!pShares) return false; - - // update our current share list - CMediaSource* pShare=NULL; - for (IVECSOURCES it = pShares->begin(); it != pShares->end(); it++) - { - if ((*it).strName == oldName) - { - (*it).strName = share.strName; - (*it).strPath = share.strPath; - (*it).vecPaths = share.vecPaths; - pShare = &(*it); - break; - } - } - - if (!pShare) - return false; - - // Update our XML file as well - return SaveSources(); -} - -// NOTE: This function does NOT save the sources.xml file - you need to call SaveSources() separately. -bool CSettings::UpdateSource(const CStdString &strType, const CStdString strOldName, const CStdString &strUpdateElement, const CStdString &strUpdateText) -{ - VECSOURCES *pShares = GetSourcesFromType(strType); - - if (!pShares) return false; - - for (IVECSOURCES it = pShares->begin(); it != pShares->end(); it++) - { - if ((*it).strName == strOldName) - { - if ("name" == strUpdateElement) - (*it).strName = strUpdateText; - else if ("lockmode" == strUpdateElement) - (*it).m_iLockMode = LockType(atoi(strUpdateText)); - else if ("lockcode" == strUpdateElement) - (*it).m_strLockCode = strUpdateText; - else if ("badpwdcount" == strUpdateElement) - (*it).m_iBadPwdCount = atoi(strUpdateText); - else if ("thumbnail" == strUpdateElement) - (*it).m_strThumbnailImage = strUpdateText; - else if ("path" == strUpdateElement) - { - (*it).vecPaths.clear(); - (*it).strPath = strUpdateText; - (*it).vecPaths.push_back(strUpdateText); - } - else - return false; - return true; - } - } - return false; -} - -bool CSettings::DeleteSource(const CStdString &strType, const CStdString strName, const CStdString strPath, bool virtualSource) -{ - VECSOURCES *pShares = GetSourcesFromType(strType); - if (!pShares) return false; - - bool found(false); - - for (IVECSOURCES it = pShares->begin(); it != pShares->end(); it++) - { - if ((*it).strName == strName && (*it).strPath == strPath) - { - CLog::Log(LOGDEBUG,"found share, removing!"); - pShares->erase(it); - found = true; - break; - } - } - - if (virtualSource) - return found; - - return SaveSources(); -} - -bool CSettings::AddShare(const CStdString &type, const CMediaSource &share) -{ - VECSOURCES *pShares = GetSourcesFromType(type); - if (!pShares) return false; - - // translate dir and add to our current shares - CStdString strPath1 = share.strPath; - strPath1.ToUpper(); - if(strPath1.IsEmpty()) - { - CLog::Log(LOGERROR, "unable to add empty path"); - return false; - } - - CMediaSource shareToAdd = share; - if (strPath1.at(0) == '$') - { - shareToAdd.strPath = CUtil::TranslateSpecialSource(strPath1); - if (!share.strPath.IsEmpty()) - CLog::Log(LOGDEBUG, "%s Translated (%s) to Path (%s)",__FUNCTION__ ,strPath1.c_str(),shareToAdd.strPath.c_str()); - else - { - CLog::Log(LOGDEBUG, "%s Skipping invalid special directory token: %s",__FUNCTION__,strPath1.c_str()); - return false; - } - } - pShares->push_back(shareToAdd); - - if (!share.m_ignore) - { - return SaveSources(); - } - return true; -} - -bool CSettings::SaveSources() -{ - // TODO: Should we be specifying utf8 here?? - CXBMCTinyXML doc; - TiXmlElement xmlRootElement("sources"); - TiXmlNode *pRoot = doc.InsertEndChild(xmlRootElement); - if (!pRoot) return false; - - // ok, now run through and save each sources section - SetSources(pRoot, "programs", m_programSources, m_defaultProgramSource); - SetSources(pRoot, "video", m_videoSources, ""); - SetSources(pRoot, "music", m_musicSources, m_defaultMusicSource); - SetSources(pRoot, "pictures", m_pictureSources, m_defaultPictureSource); - SetSources(pRoot, "files", m_fileSources, m_defaultFileSource); - - return doc.SaveFile(GetSourcesFile()); -} - -bool CSettings::SetSources(TiXmlNode *root, const char *section, const VECSOURCES &shares, const char *defaultPath) -{ - TiXmlElement sectionElement(section); - TiXmlNode *sectionNode = root->InsertEndChild(sectionElement); - if (sectionNode) - { - XMLUtils::SetPath(sectionNode, "default", defaultPath); - for (unsigned int i = 0; i < shares.size(); i++) - { - const CMediaSource &share = shares[i]; - if (share.m_ignore) - continue; - TiXmlElement source("source"); - - XMLUtils::SetString(&source, "name", share.strName); - - for (unsigned int i = 0; i < share.vecPaths.size(); i++) - XMLUtils::SetPath(&source, "path", share.vecPaths[i]); - - if (share.m_iHasLock) - { - XMLUtils::SetInt(&source, "lockmode", share.m_iLockMode); - XMLUtils::SetString(&source, "lockcode", share.m_strLockCode); - XMLUtils::SetInt(&source, "badpwdcount", share.m_iBadPwdCount); - } - if (!share.m_strThumbnailImage.IsEmpty()) - XMLUtils::SetPath(&source, "thumbnail", share.m_strThumbnailImage); - - sectionNode->InsertEndChild(source); - } - } - return true; -} - -void CSettings::LoadSources() -{ - // clear sources - m_fileSources.clear(); - m_musicSources.clear(); - m_pictureSources.clear(); - m_programSources.clear(); - m_videoSources.clear(); - - CStdString strSourcesFile = GetSourcesFile(); - CLog::Log(LOGNOTICE, "Loading media sources from %s", strSourcesFile.c_str()); - - // load xml file - CXBMCTinyXML xmlDoc; - TiXmlElement *pRootElement = NULL; - if (xmlDoc.LoadFile(strSourcesFile)) - { - pRootElement = xmlDoc.RootElement(); - if (pRootElement && strcmpi(pRootElement->Value(),"sources") != 0) - CLog::Log(LOGERROR, "%s sources.xml file does not contain <sources>", __FUNCTION__); - } - else if (CFile::Exists(strSourcesFile)) - CLog::Log(LOGERROR, "%s Error loading %s: Line %d, %s", __FUNCTION__, strSourcesFile.c_str(), xmlDoc.ErrorRow(), xmlDoc.ErrorDesc()); - - // parse sources - if (pRootElement) - { - CStdString dummy; - GetSources(pRootElement, "programs", m_programSources, m_defaultProgramSource); - GetSources(pRootElement, "pictures", m_pictureSources, m_defaultPictureSource); - GetSources(pRootElement, "files", m_fileSources, m_defaultFileSource); - GetSources(pRootElement, "music", m_musicSources, m_defaultMusicSource); - GetSources(pRootElement, "video", m_videoSources, dummy); - } -} - -void CSettings::LoadSkinSettings(const TiXmlElement* pRootElement) -{ - int number = 0; - const TiXmlElement *pElement = pRootElement->FirstChildElement("skinsettings"); - if (pElement) - { - m_skinStrings.clear(); - m_skinBools.clear(); - const TiXmlElement *pChild = pElement->FirstChildElement("setting"); - while (pChild) - { - CStdString settingName = pChild->Attribute("name"); - if (pChild->Attribute("type") && strcmpi(pChild->Attribute("type"),"string") == 0) - { // string setting - CSkinString string; - string.name = settingName; - string.value = pChild->FirstChild() ? pChild->FirstChild()->Value() : ""; - m_skinStrings.insert(pair<int, CSkinString>(number++, string)); - } - else - { // bool setting - CSkinBool setting; - setting.name = settingName; - setting.value = pChild->FirstChild() ? strcmpi(pChild->FirstChild()->Value(), "true") == 0 : false; - m_skinBools.insert(pair<int, CSkinBool>(number++, setting)); - } - pChild = pChild->NextSiblingElement("setting"); - } - } -} - -void CSettings::SaveSkinSettings(TiXmlNode *pRootElement) const -{ - // add the <skinsettings> tag - TiXmlElement xmlSettingsElement("skinsettings"); - TiXmlNode *pSettingsNode = pRootElement->InsertEndChild(xmlSettingsElement); - if (!pSettingsNode) return; - for (map<int, CSkinBool>::const_iterator it = m_skinBools.begin(); it != m_skinBools.end(); ++it) - { - // Add a <setting type="bool" name="name">true/false</setting> - TiXmlElement xmlSetting("setting"); - xmlSetting.SetAttribute("type", "bool"); - xmlSetting.SetAttribute("name", (*it).second.name.c_str()); - TiXmlText xmlBool((*it).second.value ? "true" : "false"); - xmlSetting.InsertEndChild(xmlBool); - pSettingsNode->InsertEndChild(xmlSetting); - } - for (map<int, CSkinString>::const_iterator it = m_skinStrings.begin(); it != m_skinStrings.end(); ++it) - { - // Add a <setting type="string" name="name">string</setting> - TiXmlElement xmlSetting("setting"); - xmlSetting.SetAttribute("type", "string"); - xmlSetting.SetAttribute("name", (*it).second.name.c_str()); - TiXmlText xmlLabel((*it).second.value); - xmlSetting.InsertEndChild(xmlLabel); - pSettingsNode->InsertEndChild(xmlSetting); - } -} - void CSettings::Clear() { m_vecProfiles.clear(); @@ -1411,157 +786,15 @@ void CSettings::Clear() m_logFolder.clear(); m_userAgent.clear(); - m_skinStrings.clear(); - m_skinBools.clear(); - - m_programSources.clear(); - m_pictureSources.clear(); - m_fileSources.clear(); - m_musicSources.clear(); - m_videoSources.clear(); - - m_defaultProgramSource.clear(); - m_defaultMusicSource.clear(); - m_defaultPictureSource.clear(); - m_defaultFileSource.clear(); m_defaultMusicLibSource.clear(); m_ResInfo.clear(); m_Calibrations.clear(); -#ifdef HAS_UPNP - CUPnPSettings::Get().Clear(); -#endif - CRssManager::Get().Clear(); -} + OnSettingsCleared(); -int CSettings::TranslateSkinString(const CStdString &setting) -{ - CStdString settingName; - settingName.Format("%s.%s", g_guiSettings.GetString("lookandfeel.skin").c_str(), setting); - // run through and see if we have this setting - for (map<int, CSkinString>::const_iterator it = m_skinStrings.begin(); it != m_skinStrings.end(); it++) - { - if (settingName.Equals((*it).second.name)) - return (*it).first; - } - // didn't find it - insert it - CSkinString skinString; - skinString.name = settingName; - m_skinStrings.insert(pair<int, CSkinString>(m_skinStrings.size() + m_skinBools.size(), skinString)); - return m_skinStrings.size() + m_skinBools.size() - 1; -} - -const CStdString &CSettings::GetSkinString(int setting) const -{ - map<int, CSkinString>::const_iterator it = m_skinStrings.find(setting); - if (it != m_skinStrings.end()) - { - return (*it).second.value; - } - return StringUtils::EmptyString; -} - -void CSettings::SetSkinString(int setting, const CStdString &label) -{ - map<int, CSkinString>::iterator it = m_skinStrings.find(setting); - if (it != m_skinStrings.end()) - { - (*it).second.value = label; - return; - } - assert(false); - CLog::Log(LOGFATAL, "%s : Unknown setting requested", __FUNCTION__); -} - -void CSettings::ResetSkinSetting(const CStdString &setting) -{ - CStdString settingName; - settingName.Format("%s.%s", g_guiSettings.GetString("lookandfeel.skin").c_str(), setting); - // run through and see if we have this setting as a string - for (map<int, CSkinString>::iterator it = m_skinStrings.begin(); it != m_skinStrings.end(); it++) - { - if (settingName.Equals((*it).second.name)) - { - (*it).second.value = ""; - return; - } - } - // and now check for the skin bool - for (map<int, CSkinBool>::iterator it = m_skinBools.begin(); it != m_skinBools.end(); it++) - { - if (settingName.Equals((*it).second.name)) - { - (*it).second.value = false; - return; - } - } -} - -int CSettings::TranslateSkinBool(const CStdString &setting) -{ - CStdString settingName; - settingName.Format("%s.%s", g_guiSettings.GetString("lookandfeel.skin").c_str(), setting); - // run through and see if we have this setting - for (map<int, CSkinBool>::const_iterator it = m_skinBools.begin(); it != m_skinBools.end(); it++) - { - if (settingName.Equals((*it).second.name)) - return (*it).first; - } - // didn't find it - insert it - CSkinBool skinBool; - skinBool.name = settingName; - skinBool.value = false; - m_skinBools.insert(pair<int, CSkinBool>(m_skinBools.size() + m_skinStrings.size(), skinBool)); - return m_skinBools.size() + m_skinStrings.size() - 1; -} - -bool CSettings::GetSkinBool(int setting) const -{ - map<int, CSkinBool>::const_iterator it = m_skinBools.find(setting); - if (it != m_skinBools.end()) - { - return (*it).second.value; - } - // default is to return false - return false; -} - -void CSettings::SetSkinBool(int setting, bool set) -{ - map<int, CSkinBool>::iterator it = m_skinBools.find(setting); - if (it != m_skinBools.end()) - { - (*it).second.value = set; - return; - } - assert(false); - CLog::Log(LOGFATAL,"%s : Unknown setting requested", __FUNCTION__); -} - -void CSettings::ResetSkinSettings() -{ - CStdString currentSkin = g_guiSettings.GetString("lookandfeel.skin") + "."; - // clear all the settings and strings from this skin. - map<int, CSkinBool>::iterator it = m_skinBools.begin(); - while (it != m_skinBools.end()) - { - CStdString skinName = (*it).second.name; - if (skinName.Left(currentSkin.size()) == currentSkin) - (*it).second.value = false; - - it++; - } - map<int, CSkinString>::iterator it2 = m_skinStrings.begin(); - while (it2 != m_skinStrings.end()) - { - CStdString skinName = (*it2).second.name; - if (skinName.Left(currentSkin.size()) == currentSkin) - (*it2).second.value = ""; - - it2++; - } - g_infoManager.ResetCache(); + for (SubSettings::const_iterator it = m_subSettings.begin(); it != m_subSettings.end(); it++) + (*it)->Clear(); } static CStdString ToWatchContent(const CStdString &content) @@ -1572,32 +805,6 @@ static CStdString ToWatchContent(const CStdString &content) return content; } -int CSettings::GetWatchMode(const CStdString& content) const -{ - std::map<CStdString, int>::iterator it = g_settings.m_watchMode.find(ToWatchContent(content)); - if (it != g_settings.m_watchMode.end()) - return it->second; - return VIDEO_SHOW_ALL; -} - -void CSettings::SetWatchMode(const CStdString& content, int value) -{ - std::map<CStdString, int>::iterator it = g_settings.m_watchMode.find(ToWatchContent(content)); - if (it != g_settings.m_watchMode.end()) - it->second = value; -} - -void CSettings::CycleWatchMode(const CStdString& content) -{ - std::map<CStdString, int>::iterator it = g_settings.m_watchMode.find(ToWatchContent(content)); - if (it != g_settings.m_watchMode.end()) - { - it->second++; - if (it->second > VIDEO_SHOW_WATCHED) - it->second = VIDEO_SHOW_ALL; - } -} - void CSettings::LoadUserFolderLayout() { // check them all @@ -1707,17 +914,6 @@ CStdString CSettings::GetLibraryFolder() const return folder; } -CStdString CSettings::GetSourcesFile() const -{ - CStdString folder; - if (GetCurrentProfile().hasSources()) - URIUtils::AddFileToFolder(GetProfileUserDataFolder(),"sources.xml",folder); - else - URIUtils::AddFileToFolder(GetUserDataFolder(),"sources.xml",folder); - - return folder; -} - CStdString CSettings::GetSettingsFile() const { CStdString settings; @@ -1820,3 +1016,69 @@ void CSettings::LoadMasterForLogin() if (m_currentProfile != 0) LoadProfile(0); } + +bool CSettings::OnSettingsLoading() +{ + CSingleLock lock(m_critical); + for (SettingsHandlers::const_iterator it = m_settingsHandlers.begin(); it != m_settingsHandlers.end(); it++) + { + if (!(*it)->OnSettingsLoading()) + return false; + } + + return true; +} + +void CSettings::OnSettingsLoaded() +{ + CSingleLock lock(m_critical); + for (SettingsHandlers::const_iterator it = m_settingsHandlers.begin(); it != m_settingsHandlers.end(); it++) + (*it)->OnSettingsLoaded(); +} + +bool CSettings::OnSettingsSaving() const +{ + CSingleLock lock(m_critical); + for (SettingsHandlers::const_iterator it = m_settingsHandlers.begin(); it != m_settingsHandlers.end(); it++) + { + if (!(*it)->OnSettingsSaving()) + return false; + } + + return true; +} + +void CSettings::OnSettingsSaved() const +{ + CSingleLock lock(m_critical); + for (SettingsHandlers::const_iterator it = m_settingsHandlers.begin(); it != m_settingsHandlers.end(); it++) + (*it)->OnSettingsSaved(); +} + +void CSettings::OnSettingsCleared() +{ + CSingleLock lock(m_critical); + for (SettingsHandlers::const_iterator it = m_settingsHandlers.begin(); it != m_settingsHandlers.end(); it++) + (*it)->OnSettingsCleared(); +} + +bool CSettings::Load(const TiXmlNode *settings) +{ + bool ok = true; + for (SubSettings::const_iterator it = m_subSettings.begin(); it != m_subSettings.end(); it++) + ok &= (*it)->Load(settings); + + return ok; +} + +bool CSettings::Save(TiXmlNode *settings) const +{ + CSingleLock lock(m_critical); + for (SubSettings::const_iterator it = m_subSettings.begin(); it != m_subSettings.end(); it++) + { + if (!(*it)->Save(settings)) + return false; + } + + return true; +} diff --git a/xbmc/settings/Settings.h b/xbmc/settings/Settings.h index 050f8d6f04..19729791fe 100644 --- a/xbmc/settings/Settings.h +++ b/xbmc/settings/Settings.h @@ -43,14 +43,17 @@ #endif #endif // MID +#include "settings/ISettingsHandler.h" +#include "settings/ISubSettings.h" #include "settings/VideoSettings.h" #include "Profile.h" -#include "view/ViewState.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 @@ -60,52 +63,27 @@ #define VOLUME_MAXIMUM 1.0f // 0dB #define VOLUME_DYNAMIC_RANGE 90.0f // 60dB #define VOLUME_CONTROL_STEPS 90 // 90 steps -#define VOLUME_DRC_MINIMUM 0 // 0dB -#define VOLUME_DRC_MAXIMUM 6000 // 60dB - -#define VIEW_MODE_NORMAL 0 -#define VIEW_MODE_ZOOM 1 -#define VIEW_MODE_STRETCH_4x3 2 -#define VIEW_MODE_WIDE_ZOOM 3 -#define VIEW_MODE_STRETCH_16x9 4 -#define VIEW_MODE_ORIGINAL 5 -#define VIEW_MODE_CUSTOM 6 - -#define VIDEO_SHOW_ALL 0 -#define VIDEO_SHOW_UNWATCHED 1 -#define VIDEO_SHOW_WATCHED 2 /* 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 CSkinString -{ -public: - CStdString name; - CStdString value; -}; - -class CSkinBool -{ -public: - CSkinBool() : value(false) {}; - CStdString name; - bool value; -}; - class CGUISettings; class TiXmlElement; class TiXmlNode; -class CMediaSource; -class CSettings +class CSettings : private ISettingsHandler, ISubSettings { public: CSettings(void); virtual ~CSettings(void); + void RegisterSettingsHandler(ISettingsHandler *settingsHandler); + void UnregisterSettingsHandler(ISettingsHandler *settingsHandler); + void RegisterSubSettings(ISubSettings *subSettings); + void UnregisterSubSettings(ISubSettings *subSettings); + void Initialize(); bool Load(); @@ -118,45 +96,6 @@ public: bool DeleteProfile(unsigned int index); void CreateProfileFolders(); - VECSOURCES *GetSourcesFromType(const CStdString &type); - CStdString GetDefaultSourceFromType(const CStdString &type); - - bool UpdateSource(const CStdString &strType, const CStdString strOldName, const CStdString &strUpdateChild, const CStdString &strUpdateValue); - bool DeleteSource(const CStdString &strType, const CStdString strName, const CStdString strPath, bool virtualSource = false); - bool UpdateShare(const CStdString &type, const CStdString oldName, const CMediaSource &share); - bool AddShare(const CStdString &type, const CMediaSource &share); - - int TranslateSkinString(const CStdString &setting); - const CStdString &GetSkinString(int setting) const; - void SetSkinString(int setting, const CStdString &label); - - int TranslateSkinBool(const CStdString &setting); - bool GetSkinBool(int setting) const; - void SetSkinBool(int setting, bool set); - - /*! \brief Retreive the watched mode for the given content type - \param content Current content type - \return the current watch mode for this content type, WATCH_MODE_ALL if the content type is unknown. - \sa SetWatchMode, IncrementWatchMode - */ - int GetWatchMode(const CStdString& content) const; - - /*! \brief Set the watched mode for the given content type - \param content Current content type - \param value Watched mode to set - \sa GetWatchMode, IncrementWatchMode - */ - void SetWatchMode(const CStdString& content, int value); - - /*! \brief Cycle the watched mode for the given content type - \param content Current content type - \sa GetWatchMode, SetWatchMode - */ - void CycleWatchMode(const CStdString& content); - - void ResetSkinSetting(const CStdString &setting); - void ResetSkinSettings(); - CStdString m_pictureExtensions; CStdString m_musicExtensions; CStdString m_videoExtensions; @@ -166,31 +105,10 @@ public: bool m_bMyMusicSongInfoInVis; bool m_bMyMusicSongThumbInVis; - - CViewState m_viewStateMusicNavArtists; - CViewState m_viewStateMusicNavAlbums; - CViewState m_viewStateMusicNavSongs; - CViewState m_viewStateVideoNavActors; - CViewState m_viewStateVideoNavYears; - CViewState m_viewStateVideoNavGenres; - CViewState m_viewStateVideoNavTitles; - CViewState m_viewStateVideoNavEpisodes; - CViewState m_viewStateVideoNavSeasons; - CViewState m_viewStateVideoNavTvShows; - CViewState m_viewStateVideoNavMusicVideos; - - CViewState m_viewStatePrograms; - CViewState m_viewStatePictures; - CViewState m_viewStateMusicFiles; - CViewState m_viewStateVideoFiles; - bool m_bMyMusicPlaylistRepeat; bool m_bMyMusicPlaylistShuffle; int m_iMyMusicStartWindow; - CVideoSettings m_defaultVideoSettings; - CVideoSettings m_currentVideoSettings; - float m_fZoomAmount; // current zoom amount float m_fPixelRatio; // current pixel ratio float m_fVerticalShift; // current vertical shift @@ -216,19 +134,6 @@ public: CStdString m_userAgent; - std::map<int, CSkinString> m_skinStrings; - std::map<int, CSkinBool> m_skinBools; - - VECSOURCES m_programSources; - VECSOURCES m_pictureSources; - VECSOURCES m_fileSources; - VECSOURCES m_musicSources; - VECSOURCES m_videoSources; - - CStdString m_defaultProgramSource; - CStdString m_defaultMusicSource; - CStdString m_defaultPictureSource; - CStdString m_defaultFileSource; CStdString m_defaultMusicLibSource; int m_musicNeedsUpdate; ///< if a database update means an update is required (set to the version number of the db) @@ -328,7 +233,6 @@ public: CStdString GetVideoThumbFolder() const; CStdString GetBookmarksThumbFolder() const; CStdString GetLibraryFolder() const; - CStdString GetSourcesFile() const; CStdString GetSettingsFile() const; @@ -349,41 +253,42 @@ public: bool SaveSettings(const CStdString& strSettingsFile, CGUISettings *localSettings = NULL) const; - void LoadSources(); - bool SaveSources(); - bool GetInteger(const TiXmlElement* pRootElement, const char *strTagName, int& iValue, const int iDefault, const int iMin, const int iMax); bool GetFloat(const TiXmlElement* pRootElement, const char *strTagName, float& fValue, const float fDefault, const float fMin, const float fMax); static bool GetPath(const TiXmlElement* pRootElement, const char *tagName, CStdString &strValue); static bool GetString(const TiXmlElement* pRootElement, const char *strTagName, CStdString& strValue, const CStdString& strDefaultValue); bool GetString(const TiXmlElement* pRootElement, const char *strTagName, char *szValue, const CStdString& strDefaultValue); - bool GetSource(const CStdString &category, const TiXmlNode *source, CMediaSource &share); void ApplyCalibrations(); void UpdateCalibrations(); protected: - void GetSources(const TiXmlElement* pRootElement, const CStdString& strTagName, VECSOURCES& items, CStdString& strDefault); - bool SetSources(TiXmlNode *root, const char *section, const VECSOURCES &shares, const char *defaultPath); - void GetViewState(const TiXmlElement* pRootElement, const CStdString& strTagName, CViewState &viewState, SORT_METHOD defaultSort = SORT_METHOD_LABEL, int defaultView = DEFAULT_VIEW_LIST); - - // functions for writing xml files - void SetViewState(TiXmlNode* pRootNode, const CStdString& strTagName, const CViewState &viewState) const; - bool LoadCalibration(const TiXmlElement* pElement, const CStdString& strSettingsFile); bool SaveCalibration(TiXmlNode* pRootNode) const; bool LoadSettings(const CStdString& strSettingsFile); // bool SaveSettings(const CStdString& strSettingsFile) const; - // skin activated settings - void LoadSkinSettings(const TiXmlElement* pElement); - void SaveSkinSettings(TiXmlNode *pElement) const; - void LoadUserFolderLayout(); private: + // implementation of ISettingsHandler + virtual bool OnSettingsLoading(); + virtual void OnSettingsLoaded(); + virtual bool OnSettingsSaving() const; + virtual void OnSettingsSaved() const; + virtual void OnSettingsCleared(); + + // implementation of ISubSettings + virtual bool Load(const TiXmlNode *settings); + virtual bool Save(TiXmlNode *settings) const; + + CCriticalSection m_critical; + typedef std::set<ISettingsHandler*> SettingsHandlers; + SettingsHandlers m_settingsHandlers; + typedef std::set<ISubSettings*> SubSettings; + SubSettings m_subSettings; + std::vector<CProfile> m_vecProfiles; - std::map<CStdString, int> m_watchMode; bool m_usingLoginScreen; unsigned int m_lastUsedProfile; unsigned int m_currentProfile; diff --git a/xbmc/settings/SkinSettings.cpp b/xbmc/settings/SkinSettings.cpp new file mode 100644 index 0000000000..0d9044eabf --- /dev/null +++ b/xbmc/settings/SkinSettings.cpp @@ -0,0 +1,281 @@ +/* + * 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 <string.h> + +#include "SkinSettings.h" +#include "GUIInfoManager.h" +#include "settings/GUISettings.h" +#include "threads/SingleLock.h" +#include "utils/log.h" +#include "utils/StringUtils.h" +#include "utils/XBMCTinyXML.h" + +#define XML_SKINSETTINGS "skinsettings" +#define XML_SETTING "setting" +#define XML_ATTR_TYPE "type" +#define XML_ATTR_NAME "name" + +using namespace std; + +CSkinSettings::CSkinSettings() +{ + Clear(); +} + +CSkinSettings::~CSkinSettings() +{ } + +CSkinSettings& CSkinSettings::Get() +{ + static CSkinSettings sSkinSettings; + return sSkinSettings; +} + +int CSkinSettings::TranslateString(const string &setting) +{ + std::string settingName = StringUtils::Format("%s.%s", GetCurrentSkin().c_str(), setting.c_str()); + + CSingleLock lock(m_critical); + // run through and see if we have this setting + for (map<int, CSkinString>::const_iterator it = m_strings.begin(); it != m_strings.end(); it++) + { + if (StringUtils::EqualsNoCase(settingName, it->second.name)) + return it->first; + } + + // didn't find it - insert it + CSkinString skinString; + skinString.name = settingName; + + int number = m_bools.size() + m_strings.size(); + m_strings.insert(pair<int, CSkinString>(number, skinString)); + return number; +} + +const string& CSkinSettings::GetString(int setting) const +{ + CSingleLock lock(m_critical); + map<int, CSkinString>::const_iterator it = m_strings.find(setting); + if (it != m_strings.end()) + return it->second.value; + + return StringUtils::EmptyString; +} + +void CSkinSettings::SetString(int setting, const string &label) +{ + CSingleLock lock(m_critical); + map<int, CSkinString>::iterator it = m_strings.find(setting); + if (it != m_strings.end()) + { + it->second.value = label; + return; + } + + assert(false); + CLog::Log(LOGFATAL, "%s: unknown setting (%d) requested", __FUNCTION__, setting); +} + +int CSkinSettings::TranslateBool(const string &setting) +{ + string settingName = StringUtils::Format("%s.%s", GetCurrentSkin().c_str(), setting.c_str()); + + CSingleLock lock(m_critical); + // run through and see if we have this setting + for (map<int, CSkinBool>::const_iterator it = m_bools.begin(); it != m_bools.end(); it++) + { + if (StringUtils::EqualsNoCase(settingName, it->second.name)) + return it->first; + } + + // didn't find it - insert it + CSkinBool skinBool; + skinBool.name = settingName; + skinBool.value = false; + + int number = m_bools.size() + m_strings.size(); + m_bools.insert(pair<int, CSkinBool>(number, skinBool)); + return number; +} + +bool CSkinSettings::GetBool(int setting) const +{ + CSingleLock lock(m_critical); + map<int, CSkinBool>::const_iterator it = m_bools.find(setting); + if (it != m_bools.end()) + return it->second.value; + + // default is to return false + return false; +} + +void CSkinSettings::SetBool(int setting, bool set) +{ + CSingleLock lock(m_critical); + map<int, CSkinBool>::iterator it = m_bools.find(setting); + if (it != m_bools.end()) + { + it->second.value = set; + return; + } + + assert(false); + CLog::Log(LOGFATAL,"%s: unknown setting (%d) requested", __FUNCTION__, setting); +} + +void CSkinSettings::Reset(const string &setting) +{ + string settingName = StringUtils::Format("%s.%s", GetCurrentSkin().c_str(), setting.c_str()); + + CSingleLock lock(m_critical); + // run through and see if we have this setting as a string + for (map<int, CSkinString>::iterator it = m_strings.begin(); it != m_strings.end(); it++) + { + if (StringUtils::EqualsNoCase(settingName, it->second.name)) + { + it->second.value.clear(); + return; + } + } + + // and now check for the skin bool + for (map<int, CSkinBool>::iterator it = m_bools.begin(); it != m_bools.end(); it++) + { + if (StringUtils::EqualsNoCase(settingName, it->second.name)) + { + it->second.value = false; + return; + } + } +} + +void CSkinSettings::Reset() +{ + string currentSkin = GetCurrentSkin() + "."; + + CSingleLock lock(m_critical); + // clear all the settings and strings from this skin. + for (map<int, CSkinBool>::iterator it = m_bools.begin(); it != m_bools.end(); it++) + { + if (StringUtils::StartsWith(it->second.name, currentSkin)) + it->second.value = false; + } + + for (map<int, CSkinString>::iterator it = m_strings.begin(); it != m_strings.end(); it++) + { + if (StringUtils::StartsWith(it->second.name, currentSkin)) + it->second.value.clear(); + } + + g_infoManager.ResetCache(); +} + +bool CSkinSettings::Load(const TiXmlNode *settings) +{ + if (settings == NULL) + return false; + + const TiXmlElement *pElement = settings->FirstChildElement(XML_SKINSETTINGS); + if (pElement == NULL) + { + CLog::Log(LOGWARNING, "CSkinSettings: no <skinsettings> tag found"); + return false; + } + + CSingleLock lock(m_critical); + m_strings.clear(); + m_bools.clear(); + + int number = 0; + const TiXmlElement *pChild = pElement->FirstChildElement(XML_SETTING); + while (pChild) + { + CStdString settingName = pChild->Attribute(XML_ATTR_NAME); + if (pChild->Attribute("type") && StringUtils::EqualsNoCase(pChild->Attribute(XML_ATTR_TYPE), "string")) + { // string setting + CSkinString string; + string.name = settingName; + string.value = pChild->FirstChild() ? pChild->FirstChild()->Value() : ""; + m_strings.insert(pair<int, CSkinString>(number++, string)); + } + else + { // bool setting + CSkinBool setting; + setting.name = settingName; + setting.value = pChild->FirstChild() ? StringUtils::EqualsNoCase(pChild->FirstChild()->Value(), "true") : false; + m_bools.insert(pair<int, CSkinBool>(number++, setting)); + } + pChild = pChild->NextSiblingElement(XML_SETTING); + } + + return true; +} + +bool CSkinSettings::Save(TiXmlNode *settings) const +{ + if (settings == NULL) + return false; + + CSingleLock lock(m_critical); + // add the <skinsettings> tag + TiXmlElement xmlSettingsElement(XML_SKINSETTINGS); + TiXmlNode *pSettingsNode = settings->InsertEndChild(xmlSettingsElement); + if (pSettingsNode == NULL) + { + CLog::Log(LOGWARNING, "CSkinSettings: could not create <skinsettings> tag"); + return false; + } + + for (map<int, CSkinBool>::const_iterator it = m_bools.begin(); it != m_bools.end(); ++it) + { + // Add a <setting type="bool" name="name">true/false</setting> + TiXmlElement xmlSetting(XML_SETTING); + xmlSetting.SetAttribute(XML_ATTR_TYPE, "bool"); + xmlSetting.SetAttribute(XML_ATTR_NAME, (*it).second.name.c_str()); + TiXmlText xmlBool((*it).second.value ? "true" : "false"); + xmlSetting.InsertEndChild(xmlBool); + pSettingsNode->InsertEndChild(xmlSetting); + } + for (map<int, CSkinString>::const_iterator it = m_strings.begin(); it != m_strings.end(); ++it) + { + // Add a <setting type="string" name="name">string</setting> + TiXmlElement xmlSetting(XML_SETTING); + xmlSetting.SetAttribute(XML_ATTR_TYPE, "string"); + xmlSetting.SetAttribute(XML_ATTR_NAME, (*it).second.name.c_str()); + TiXmlText xmlLabel((*it).second.value); + xmlSetting.InsertEndChild(xmlLabel); + pSettingsNode->InsertEndChild(xmlSetting); + } + + return true; +} + +void CSkinSettings::Clear() +{ + CSingleLock lock(m_critical); + m_strings.clear(); + m_bools.clear(); +} + +std::string CSkinSettings::GetCurrentSkin() const +{ + return g_guiSettings.GetString("lookandfeel.skin"); +}
\ No newline at end of file diff --git a/xbmc/settings/SkinSettings.h b/xbmc/settings/SkinSettings.h new file mode 100644 index 0000000000..d7f2fab547 --- /dev/null +++ b/xbmc/settings/SkinSettings.h @@ -0,0 +1,80 @@ +#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 <map> +#include <string> + +#include "settings/ISubSettings.h" +#include "threads/CriticalSection.h" + +class TiXmlNode; + +class CSkinString +{ +public: + std::string name; + std::string value; +}; + +class CSkinBool +{ +public: + CSkinBool() + : value(false) + { } + + std::string name; + bool value; +}; + +class CSkinSettings : public ISubSettings +{ +public: + static CSkinSettings& Get(); + + virtual bool Load(const TiXmlNode *settings); + virtual bool Save(TiXmlNode *settings) const; + virtual void Clear(); + + int TranslateString(const std::string &setting); + const std::string& GetString(int setting) const; + void SetString(int setting, const std::string &label); + + int TranslateBool(const std::string &setting); + bool GetBool(int setting) const; + void SetBool(int setting, bool set); + + void Reset(const std::string &setting); + void Reset(); + +protected: + CSkinSettings(); + CSkinSettings(const CSkinSettings&); + CSkinSettings const& operator=(CSkinSettings const&); + virtual ~CSkinSettings(); + + std::string GetCurrentSkin() const; + +private: + std::map<int, CSkinString> m_strings; + std::map<int, CSkinBool> m_bools; + CCriticalSection m_critical; +};
\ No newline at end of file diff --git a/xbmc/settings/VideoSettings.cpp b/xbmc/settings/VideoSettings.cpp index 5b5ead0db0..556288e8af 100644 --- a/xbmc/settings/VideoSettings.cpp +++ b/xbmc/settings/VideoSettings.cpp @@ -33,7 +33,7 @@ CVideoSettings::CVideoSettings() m_DeinterlaceMode = VS_DEINTERLACEMODE_OFF; m_InterlaceMethod = VS_INTERLACEMETHOD_AUTO; m_ScalingMethod = VS_SCALINGMETHOD_LINEAR; - m_ViewMode = VIEW_MODE_NORMAL; + m_ViewMode = ViewModeNormal; m_CustomZoomAmount = 1.0f; m_CustomPixelRatio = 1.0f; m_CustomVerticalShift = 0.0f; diff --git a/xbmc/settings/VideoSettings.h b/xbmc/settings/VideoSettings.h index fe4f0032c5..3ca4c8b89f 100644 --- a/xbmc/settings/VideoSettings.h +++ b/xbmc/settings/VideoSettings.h @@ -94,6 +94,16 @@ enum ESCALINGMETHOD VS_SCALINGMETHOD_MAX // do not use and keep as last enum value. }; +typedef enum { + ViewModeNormal = 0, + ViewModeZoom, + ViewModeStretch4x3, + ViewModeWideZoom, + ViewModeStretch16x9, + ViewModeOriginal, + ViewModeCustom +} ViewMode; + class CVideoSettings { public: diff --git a/xbmc/settings/windows/GUIWindowSettingsCategory.cpp b/xbmc/settings/windows/GUIWindowSettingsCategory.cpp index 2a4c62988f..4a94ecc346 100644 --- a/xbmc/settings/windows/GUIWindowSettingsCategory.cpp +++ b/xbmc/settings/windows/GUIWindowSettingsCategory.cpp @@ -35,6 +35,7 @@ #include "music/MusicDatabase.h" #include "video/VideoDatabase.h" #include "view/ViewDatabase.h" +#include "view/ViewState.h" #include "PlayListPlayer.h" #include "addons/Skin.h" #include "guilib/GUIAudioManager.h" @@ -87,6 +88,7 @@ #include <map> #include "settings/Settings.h" #include "settings/AdvancedSettings.h" +#include "settings/MediaSourceSettings.h" #include "input/MouseStat.h" #if defined(TARGET_WINDOWS) #include "input/windows/WINJoystick.h" @@ -1570,7 +1572,7 @@ void CGUIWindowSettingsCategory::OnSettingChanged(BaseSettingControlPtr pSetting else if (strSetting.Equals("subtitles.custompath")) { bWriteOnly = false; - shares = g_settings.m_videoSources; + shares = *CMediaSourceSettings::Get().GetSources("video"); } g_mediaManager.GetNetworkLocations(shares); diff --git a/xbmc/storage/MediaManager.cpp b/xbmc/storage/MediaManager.cpp index 545813a954..f3758e84f7 100644 --- a/xbmc/storage/MediaManager.cpp +++ b/xbmc/storage/MediaManager.cpp @@ -38,6 +38,7 @@ #include "Autorun.h" #include "GUIUserMessages.h" #include "settings/Settings.h" +#include "settings/MediaSourceSettings.h" #include "utils/XBMCTinyXML.h" #include "threads/SingleLock.h" #include "utils/log.h" @@ -273,11 +274,11 @@ bool CMediaManager::SetLocationPath(const CStdString& oldPath, const CStdString& void CMediaManager::AddAutoSource(const CMediaSource &share, bool bAutorun) { - g_settings.AddShare("files",share); - g_settings.AddShare("video",share); - g_settings.AddShare("pictures",share); - g_settings.AddShare("music",share); - g_settings.AddShare("programs",share); + CMediaSourceSettings::Get().AddShare("files", share); + CMediaSourceSettings::Get().AddShare("video", share); + CMediaSourceSettings::Get().AddShare("pictures", share); + CMediaSourceSettings::Get().AddShare("music", share); + CMediaSourceSettings::Get().AddShare("programs", share); CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE_SOURCES); g_windowManager.SendThreadMessage( msg ); @@ -289,11 +290,11 @@ void CMediaManager::AddAutoSource(const CMediaSource &share, bool bAutorun) void CMediaManager::RemoveAutoSource(const CMediaSource &share) { - g_settings.DeleteSource("files", share.strName, share.strPath, true); - g_settings.DeleteSource("video", share.strName, share.strPath, true); - g_settings.DeleteSource("pictures", share.strName, share.strPath, true); - g_settings.DeleteSource("music", share.strName, share.strPath, true); - g_settings.DeleteSource("programs", share.strName, share.strPath, true); + CMediaSourceSettings::Get().DeleteSource("files", share.strName, share.strPath, true); + CMediaSourceSettings::Get().DeleteSource("video", share.strName, share.strPath, true); + CMediaSourceSettings::Get().DeleteSource("pictures", share.strName, share.strPath, true); + CMediaSourceSettings::Get().DeleteSource("music", share.strName, share.strPath, true); + CMediaSourceSettings::Get().DeleteSource("programs", share.strName, share.strPath, true); CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE_SOURCES); g_windowManager.SendThreadMessage( msg ); diff --git a/xbmc/utils/RssManager.cpp b/xbmc/utils/RssManager.cpp index 3eda16f294..7e5b57fb3a 100644 --- a/xbmc/utils/RssManager.cpp +++ b/xbmc/utils/RssManager.cpp @@ -45,6 +45,16 @@ CRssManager& CRssManager::Get() return sRssManager; } +void CRssManager::OnSettingsLoaded() +{ + Load(); +} + +void CRssManager::OnSettingsCleared() +{ + Clear(); +} + void CRssManager::Start() { m_bActive = true; diff --git a/xbmc/utils/RssManager.h b/xbmc/utils/RssManager.h index 86d01e9f62..5277876c67 100644 --- a/xbmc/utils/RssManager.h +++ b/xbmc/utils/RssManager.h @@ -25,6 +25,8 @@ #include "threads/CriticalSection.h" +#include "settings/ISettingsHandler.h" + class CRssReader; class IRssObserver; @@ -36,11 +38,14 @@ typedef struct } RssSet; typedef std::map<int, RssSet> RssUrls; -class CRssManager +class CRssManager : public ISettingsHandler { public: static CRssManager& Get(); + virtual void OnSettingsLoaded(); + virtual void OnSettingsCleared(); + void Start(); void Stop(); bool Load(); diff --git a/xbmc/utils/SaveFileStateJob.h b/xbmc/utils/SaveFileStateJob.h index 6839005ce3..0d24dff601 100644 --- a/xbmc/utils/SaveFileStateJob.h +++ b/xbmc/utils/SaveFileStateJob.h @@ -6,6 +6,7 @@ #include "FileItem.h" #include "pvr/PVRManager.h" #include "pvr/recordings/PVRRecordings.h" +#include "settings/MediaSettings.h" class CSaveFileStateJob : public CJob { @@ -91,9 +92,9 @@ bool CSaveFileStateJob::DoWork() } } - if (g_settings.m_currentVideoSettings != g_settings.m_defaultVideoSettings) + if (CMediaSettings::Get().GetCurrentVideoSettings() != CMediaSettings::Get().GetDefaultVideoSettings()) { - videodatabase.SetVideoSettings(progressTrackingFile, g_settings.m_currentVideoSettings); + videodatabase.SetVideoSettings(progressTrackingFile, CMediaSettings::Get().GetCurrentVideoSettings()); } if (m_item.HasVideoInfoTag() && m_item.GetVideoInfoTag()->HasStreamDetails()) diff --git a/xbmc/utils/StringUtils.cpp b/xbmc/utils/StringUtils.cpp index ba4546912a..bdd6f5df12 100644 --- a/xbmc/utils/StringUtils.cpp +++ b/xbmc/utils/StringUtils.cpp @@ -46,6 +46,7 @@ const char* ADDON_GUID_RE = "^(\\{){0,1}[0-9a-fA-F]{8}\\-[0-9a-fA-F]{4}\\-[0-9a- /* empty string for use in returns by ref */ const CStdString StringUtils::EmptyString = ""; +const std::string StringUtils::Empty = ""; CStdString StringUtils::m_lastUUID = ""; string StringUtils::Format(const char *fmt, ...) diff --git a/xbmc/utils/StringUtils.h b/xbmc/utils/StringUtils.h index e4c9e5bb12..7928624890 100644 --- a/xbmc/utils/StringUtils.h +++ b/xbmc/utils/StringUtils.h @@ -106,6 +106,7 @@ public: static bool IsInteger(const CStdString& str); static CStdString SizeToString(int64_t size); static const CStdString EmptyString; + static const std::string Empty; static size_t FindWords(const char *str, const char *wordLowerCase); static int FindEndBracket(const CStdString &str, char opener, char closer, int startPos = 0); static int DateStringToYYYYMMDD(const CStdString &dateString); diff --git a/xbmc/video/GUIViewStateVideo.cpp b/xbmc/video/GUIViewStateVideo.cpp index 5b2b67ee1e..18baf2ce62 100644 --- a/xbmc/video/GUIViewStateVideo.cpp +++ b/xbmc/video/GUIViewStateVideo.cpp @@ -27,10 +27,13 @@ #include "VideoDatabase.h" #include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" +#include "settings/MediaSettings.h" +#include "settings/MediaSourceSettings.h" #include "settings/Settings.h" #include "FileItem.h" #include "guilib/WindowIDs.h" #include "guilib/LocalizeStrings.h" +#include "view/ViewStateSettings.h" using namespace XFILE; using namespace VIDEODATABASEDIRECTORY; @@ -77,23 +80,25 @@ CGUIViewStateWindowVideoFiles::CGUIViewStateWindowVideoFiles(const CFileItemList AddSortMethod(SORT_METHOD_SIZE, 553, LABEL_MASKS("%L", "%I", "%L", "%I")); // Label, Size | Label, Size AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // Label, Date | Label, Date AddSortMethod(SORT_METHOD_FILE, 561, LABEL_MASKS("%L", "%I", "%L", "")); // Label, Size | Label, empty - - SetSortMethod(g_settings.m_viewStateVideoFiles.m_sortMethod); - SetViewAsControl(g_settings.m_viewStateVideoFiles.m_viewMode); - SetSortOrder(g_settings.m_viewStateVideoFiles.m_sortOrder); + + CViewState *viewState = CViewStateSettings::Get().Get("videofiles"); + SetSortMethod(viewState->m_sortMethod); + SetViewAsControl(viewState->m_viewMode); + SetSortOrder(viewState->m_sortOrder); } LoadViewState(items.GetPath(), WINDOW_VIDEO_FILES); } void CGUIViewStateWindowVideoFiles::SaveViewState() { - SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_FILES, &g_settings.m_viewStateVideoFiles); + SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_FILES, CViewStateSettings::Get().Get("videofiles")); } VECSOURCES& CGUIViewStateWindowVideoFiles::GetSources() { - AddOrReplace(g_settings.m_videoSources, CGUIViewStateWindowVideo::GetSources()); - return g_settings.m_videoSources; + VECSOURCES *videoSources = CMediaSourceSettings::Get().GetSources("video"); + AddOrReplace(*videoSources, CGUIViewStateWindowVideo::GetSources()); + return *videoSources; } CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& items) : CGUIViewStateWindowVideo(items) @@ -134,30 +139,30 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it { AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", "%R", "%L", "")); // Title, Rating | Label, empty SetSortMethod(SORT_METHOD_LABEL); - - SetViewAsControl(g_settings.m_viewStateVideoNavActors.m_viewMode); - - SetSortOrder(g_settings.m_viewStateVideoNavActors.m_sortOrder); + + CViewState *viewState = CViewStateSettings::Get().Get("videonavactors"); + SetViewAsControl(viewState->m_viewMode); + SetSortOrder(viewState->m_sortOrder); } break; case NODE_TYPE_YEAR: { AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", "%R", "%L", "")); // Title, Rating | Label, empty SetSortMethod(SORT_METHOD_LABEL); - - SetViewAsControl(g_settings.m_viewStateVideoNavYears.m_viewMode); - - SetSortOrder(g_settings.m_viewStateVideoNavYears.m_sortOrder); + + CViewState *viewState = CViewStateSettings::Get().Get("videonavyears"); + SetViewAsControl(viewState->m_viewMode); + SetSortOrder(viewState->m_sortOrder); } break; case NODE_TYPE_SEASONS: { AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556, LABEL_MASKS("%L", "","%L","")); // Label, empty | Label, empty SetSortMethod(SORT_METHOD_VIDEO_SORT_TITLE); - - SetViewAsControl(g_settings.m_viewStateVideoNavSeasons.m_viewMode); - - SetSortOrder(g_settings.m_viewStateVideoNavSeasons.m_sortOrder); + + CViewState *viewState = CViewStateSettings::Get().Get("videonavseasons"); + SetViewAsControl(viewState->m_viewMode); + SetSortOrder(viewState->m_sortOrder); } break; case NODE_TYPE_TITLE_TVSHOWS: @@ -172,10 +177,10 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it AddSortMethod(SORT_METHOD_LASTPLAYED, 568, LABEL_MASKS("%T", "%p", "%T", "%p")); // Title, #Last played | Title, #Last played AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%L","%Y","%L","%Y")); // Label, Year | Label, Year SetSortMethod(SORT_METHOD_LABEL); - - SetViewAsControl(g_settings.m_viewStateVideoNavTvShows.m_viewMode); - - SetSortOrder(g_settings.m_viewStateVideoNavTvShows.m_sortOrder); + + CViewState *viewState = CViewStateSettings::Get().Get("videonavtvshows"); + SetViewAsControl(viewState->m_viewMode); + SetSortOrder(viewState->m_sortOrder); } break; case NODE_TYPE_MUSICVIDEOS_ALBUM: @@ -185,10 +190,10 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it { AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", "%R", "%L", "")); // Title, Rating | Label, empty SetSortMethod(SORT_METHOD_LABEL); - - SetViewAsControl(g_settings.m_viewStateVideoNavGenres.m_viewMode); - - SetSortOrder(g_settings.m_viewStateVideoNavGenres.m_sortOrder); + + CViewState *viewState = CViewStateSettings::Get().Get("videonavgenres"); + SetViewAsControl(viewState->m_viewMode); + SetSortOrder(viewState->m_sortOrder); } break; case NODE_TYPE_SETS: @@ -202,14 +207,14 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it AddSortMethod(SORT_METHOD_VIDEO_RATING, 563, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating AddSortMethod(SORT_METHOD_DATEADDED, 570, LABEL_MASKS("%T", "%a", "%T", "%a")); // Title, DateAdded | Title, DateAdded - if (g_settings.GetWatchMode(items.GetContent()) == VIDEO_SHOW_ALL) + if (CMediaSettings::Get().GetWatchedMode(items.GetContent()) == WatchedModeAll) AddSortMethod(SORT_METHOD_PLAYCOUNT, 567, LABEL_MASKS("%T", "%V", "%T", "%V")); // Title, Playcount | Title, Playcount SetSortMethod(SORT_METHOD_LABEL_IGNORE_THE); - - SetViewAsControl(g_settings.m_viewStateVideoNavGenres.m_viewMode); - - SetSortOrder(g_settings.m_viewStateVideoNavGenres.m_sortOrder); + + CViewState *viewState = CViewStateSettings::Get().Get("videonavgenres"); + SetViewAsControl(viewState->m_viewMode); + SetSortOrder(viewState->m_sortOrder); } break; case NODE_TYPE_TAGS: @@ -220,8 +225,10 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it AddSortMethod(method, 551, LABEL_MASKS("%T","", "%T","")); // Title, empty | Title, empty SetSortMethod(method); - SetViewAsControl(g_settings.m_viewStateVideoNavGenres.m_viewMode); - SetSortOrder(g_settings.m_viewStateVideoNavGenres.m_sortOrder); + + CViewState *viewState = CViewStateSettings::Get().Get("videonavgenres"); + SetViewAsControl(viewState->m_viewMode); + SetSortOrder(viewState->m_sortOrder); } break; case NODE_TYPE_EPISODES: @@ -234,7 +241,7 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it AddSortMethod(SORT_METHOD_PRODUCTIONCODE, 20368, LABEL_MASKS("%E. %T","%P", "%E. %T","%P")); // Episode. Title, ProductionCode | Episode. Title, ProductionCode AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%E. %T","%J","%E. %T","%J")); // Episode. Title, Date | Episode. Title, Date - if (g_settings.GetWatchMode(items.GetContent()) == VIDEO_SHOW_ALL) + if (CMediaSettings::Get().GetWatchedMode(items.GetContent()) == WatchedModeAll) AddSortMethod(SORT_METHOD_PLAYCOUNT, 567, LABEL_MASKS("%E. %T", "%V")); // Episode. Title, Playcount | empty, empty } else @@ -245,19 +252,18 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it AddSortMethod(SORT_METHOD_PRODUCTIONCODE, 20368, LABEL_MASKS("%H. %T","%P", "%H. %T","%P")); // Order. Title, ProductionCode | Episode. Title, ProductionCode AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%H. %T","%J","%H. %T","%J")); // Order. Title, Date | Episode. Title, Date - if (g_settings.GetWatchMode(items.GetContent()) == VIDEO_SHOW_ALL) + if (CMediaSettings::Get().GetWatchedMode(items.GetContent()) == WatchedModeAll) AddSortMethod(SORT_METHOD_PLAYCOUNT, 567, LABEL_MASKS("%H. %T", "%V")); // Order. Title, Playcount | empty, empty } if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%T","%R")); // Title, Rating | empty, empty else AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", "%R")); // Title, Rating | empty, empty - - SetSortMethod(g_settings.m_viewStateVideoNavEpisodes.m_sortMethod); - - SetViewAsControl(g_settings.m_viewStateVideoNavEpisodes.m_viewMode); - - SetSortOrder(g_settings.m_viewStateVideoNavEpisodes.m_sortOrder); + + CViewState *viewState = CViewStateSettings::Get().Get("videonavepisodes"); + SetSortMethod(viewState->m_sortMethod); + SetViewAsControl(viewState->m_viewMode); + SetSortOrder(viewState->m_sortOrder); break; } case NODE_TYPE_RECENTLY_ADDED_EPISODES: @@ -265,7 +271,7 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it AddSortMethod(SORT_METHOD_NONE, 552, LABEL_MASKS("%Z - %H. %T", "%R")); // TvShow - Order. Title, Rating | empty, empty SetSortMethod(SORT_METHOD_NONE); - SetViewAsControl(g_settings.m_viewStateVideoNavEpisodes.m_viewMode); + SetViewAsControl(CViewStateSettings::Get().Get("videonavepisodes")->m_viewMode); SetSortOrder(SortOrderNone); break; @@ -295,17 +301,17 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it AddSortMethod(SORT_METHOD_VIDEO_RUNTIME, 180, LABEL_MASKS("%T", "%D")); // Title, Duration | empty, empty AddSortMethod(SORT_METHOD_DATEADDED, 570, LABEL_MASKS("%T", "%a", "%T", "%a")); // Title, DateAdded | Title, DateAdded - if (g_settings.GetWatchMode(items.GetContent()) == VIDEO_SHOW_ALL) + if (CMediaSettings::Get().GetWatchedMode(items.GetContent()) == WatchedModeAll) AddSortMethod(SORT_METHOD_PLAYCOUNT, 567, LABEL_MASKS("%T", "%V", "%T", "%V")); // Title, Playcount | Title, Playcount - + + CViewState *viewState = CViewStateSettings::Get().Get("videonavtitles"); if (params.GetSetId() > -1) SetSortMethod(SORT_METHOD_YEAR); else - SetSortMethod(g_settings.m_viewStateVideoNavTitles.m_sortMethod); - - SetViewAsControl(g_settings.m_viewStateVideoNavTitles.m_viewMode); + SetSortMethod(viewState->m_sortMethod); - SetSortOrder(g_settings.m_viewStateVideoNavTitles.m_sortOrder); + SetViewAsControl(viewState->m_viewMode); + SetSortOrder(viewState->m_sortOrder); } break; case NODE_TYPE_TITLE_MUSICVIDEOS: @@ -327,18 +333,17 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%B - %T", "%Y")); // Album - Title, Year | empty, empty } - if (g_settings.GetWatchMode(items.GetContent()) == VIDEO_SHOW_ALL) + if (CMediaSettings::Get().GetWatchedMode(items.GetContent()) == WatchedModeAll) AddSortMethod(SORT_METHOD_PLAYCOUNT, 567, LABEL_MASKS("%T", "%V")); // Title, Playcount | empty, empty CStdString strTrackLeft=g_guiSettings.GetString("musicfiles.trackformat"); CStdString strTrackRight=g_guiSettings.GetString("musicfiles.trackformatright"); AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined | empty, empty - - SetSortMethod(g_settings.m_viewStateVideoNavMusicVideos.m_sortMethod); - - SetViewAsControl(g_settings.m_viewStateVideoNavMusicVideos.m_viewMode); - - SetSortOrder(g_settings.m_viewStateVideoNavMusicVideos.m_sortOrder); + + CViewState *viewState = CViewStateSettings::Get().Get("videonavmusicvideos"); + SetSortMethod(viewState->m_sortMethod); + SetViewAsControl(viewState->m_viewMode); + SetSortOrder(viewState->m_sortOrder); } break; case NODE_TYPE_RECENTLY_ADDED_MOVIES: @@ -346,7 +351,7 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it AddSortMethod(SORT_METHOD_NONE, 552, LABEL_MASKS("%T", "%R")); // Title, Rating | empty, empty SetSortMethod(SORT_METHOD_NONE); - SetViewAsControl(g_settings.m_viewStateVideoNavTitles.m_viewMode); + SetViewAsControl(CViewStateSettings::Get().Get("videonavtitles")->m_viewMode); SetSortOrder(SortOrderNone); } @@ -356,7 +361,7 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it AddSortMethod(SORT_METHOD_NONE, 552, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty SetSortMethod(SORT_METHOD_NONE); - SetViewAsControl(g_settings.m_viewStateVideoNavMusicVideos.m_viewMode); + SetViewAsControl(CViewStateSettings::Get().Get("videonavmusicvideos")->m_viewMode); SetSortOrder(SortOrderNone); } @@ -375,9 +380,10 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // Label, Date | Label, Date AddSortMethod(SORT_METHOD_FILE, 561, LABEL_MASKS("%L", "%I", "%L", "")); // Label, Size | Label, empty - SetSortMethod(g_settings.m_viewStateVideoFiles.m_sortMethod); - SetViewAsControl(g_settings.m_viewStateVideoFiles.m_viewMode); - SetSortOrder(g_settings.m_viewStateVideoFiles.m_sortOrder); + CViewState *viewState = CViewStateSettings::Get().Get("videofiles"); + SetSortMethod(viewState->m_sortMethod); + SetViewAsControl(viewState->m_viewMode); + SetSortOrder(viewState->m_sortOrder); } LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV); } @@ -392,28 +398,28 @@ void CGUIViewStateWindowVideoNav::SaveViewState() switch (NodeType) { case NODE_TYPE_ACTOR: - SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, &g_settings.m_viewStateVideoNavActors); + SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavactors")); break; case NODE_TYPE_YEAR: - SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, &g_settings.m_viewStateVideoNavYears); + SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavyears")); break; case NODE_TYPE_GENRE: - SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, &g_settings.m_viewStateVideoNavGenres); + SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavgenres")); break; case NODE_TYPE_TITLE_MOVIES: - SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, params.GetSetId() > -1 ? NULL : &g_settings.m_viewStateVideoNavTitles); + SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, params.GetSetId() > -1 ? NULL : CViewStateSettings::Get().Get("videonavtitles")); break; case NODE_TYPE_EPISODES: - SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, &g_settings.m_viewStateVideoNavEpisodes); + SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavepisodes")); break; case NODE_TYPE_TITLE_TVSHOWS: - SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, &g_settings.m_viewStateVideoNavTvShows); + SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavtvshows")); break; case NODE_TYPE_SEASONS: - SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, &g_settings.m_viewStateVideoNavSeasons); + SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavseasons")); break; case NODE_TYPE_TITLE_MUSICVIDEOS: - SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, &g_settings.m_viewStateVideoNavMusicVideos); + SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV,CViewStateSettings::Get().Get("videonavmusicvideos")); break; default: SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV); @@ -422,7 +428,7 @@ void CGUIViewStateWindowVideoNav::SaveViewState() } else { - SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, &g_settings.m_viewStateVideoFiles); + SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videofiles")); } } @@ -509,22 +515,23 @@ CGUIViewStateVideoMovies::CGUIViewStateVideoMovies(const CFileItemList& items) : AddSortMethod(SORT_METHOD_MPAA_RATING, 20074, LABEL_MASKS("%T", "%O")); // Title, MPAA | empty, empty AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%T", "%Y", "%T", "%Y")); // Title, Year | Title, Year + CViewState *viewState = CViewStateSettings::Get().Get("videonavtitles"); if (items.IsSmartPlayList() || items.GetProperty("library.filter").asBoolean()) AddPlaylistOrder(items, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating else { - SetSortMethod(g_settings.m_viewStateVideoNavTitles.m_sortMethod); - SetSortOrder(g_settings.m_viewStateVideoNavTitles.m_sortOrder); + SetSortMethod(viewState->m_sortMethod); + SetSortOrder(viewState->m_sortOrder); } - SetViewAsControl(g_settings.m_viewStateVideoNavTitles.m_viewMode); + SetViewAsControl(viewState->m_viewMode); LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV); } void CGUIViewStateVideoMovies::SaveViewState() { - SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, &g_settings.m_viewStateVideoNavTitles); + SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavtitles")); } @@ -552,23 +559,24 @@ CGUIViewStateVideoMusicVideos::CGUIViewStateVideoMusicVideos(const CFileItemList CStdString strTrackLeft=g_guiSettings.GetString("musicfiles.trackformat"); CStdString strTrackRight=g_guiSettings.GetString("musicfiles.trackformatright"); AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined | empty, empty - + + CViewState *viewState = CViewStateSettings::Get().Get("videonavmusicvideos"); if (items.IsSmartPlayList() || items.GetProperty("library.filter").asBoolean()) AddPlaylistOrder(items, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty else { - SetSortMethod(g_settings.m_viewStateVideoNavMusicVideos.m_sortMethod); - SetSortOrder(g_settings.m_viewStateVideoNavMusicVideos.m_sortOrder); + SetSortMethod(viewState->m_sortMethod); + SetSortOrder(viewState->m_sortOrder); } - SetViewAsControl(g_settings.m_viewStateVideoNavMusicVideos.m_viewMode); + SetViewAsControl(viewState->m_viewMode); LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV); } void CGUIViewStateVideoMusicVideos::SaveViewState() { - SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, &g_settings.m_viewStateVideoNavMusicVideos); + SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavmusicvideos")); } CGUIViewStateVideoTVShows::CGUIViewStateVideoTVShows(const CFileItemList& items) : CGUIViewStateWindowVideo(items) @@ -578,23 +586,24 @@ CGUIViewStateVideoTVShows::CGUIViewStateVideoTVShows(const CFileItemList& items) else AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556, LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%T", "%Y", "%T", "%Y")); // Title, Year | Title, Year - + + CViewState *viewState = CViewStateSettings::Get().Get("videonavtvshows"); if (items.IsSmartPlayList() || items.GetProperty("library.filter").asBoolean()) AddPlaylistOrder(items, LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes else { - SetSortMethod(g_settings.m_viewStateVideoNavTvShows.m_sortMethod); - SetSortOrder(g_settings.m_viewStateVideoNavTvShows.m_sortOrder); + SetSortMethod(viewState->m_sortMethod); + SetSortOrder(viewState->m_sortOrder); } - SetViewAsControl(g_settings.m_viewStateVideoNavTvShows.m_viewMode); + SetViewAsControl(viewState->m_viewMode); LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV); } void CGUIViewStateVideoTVShows::SaveViewState() { - SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, &g_settings.m_viewStateVideoNavTvShows); + SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavtvshows")); } @@ -620,22 +629,23 @@ CGUIViewStateVideoEpisodes::CGUIViewStateVideoEpisodes(const CFileItemList& item AddSortMethod(SORT_METHOD_PRODUCTIONCODE, 20368, LABEL_MASKS("%Z - %H. %T","%P")); // TvShow - Order. Title, Production Code | empty, empty AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%Z - %H. %T","%J")); // TvShow - Order. Title, Date | empty, empty } - + + CViewState *viewState = CViewStateSettings::Get().Get("videonavepisodes"); if (items.IsSmartPlayList() || items.GetProperty("library.filter").asBoolean()) AddPlaylistOrder(items, LABEL_MASKS("%Z - %H. %T", "%R")); // TvShow - Order. Title, Rating | empty, empty else { - SetSortMethod(g_settings.m_viewStateVideoNavEpisodes.m_sortMethod); - SetSortOrder(g_settings.m_viewStateVideoNavEpisodes.m_sortOrder); + SetSortMethod(viewState->m_sortMethod); + SetSortOrder(viewState->m_sortOrder); } - SetViewAsControl(g_settings.m_viewStateVideoNavEpisodes.m_viewMode); + SetViewAsControl(viewState->m_viewMode); LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV); } void CGUIViewStateVideoEpisodes::SaveViewState() { - SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, &g_settings.m_viewStateVideoNavEpisodes); + SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavepisodes")); } diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp index 4727fe5cef..43957e61c0 100644 --- a/xbmc/video/VideoDatabase.cpp +++ b/xbmc/video/VideoDatabase.cpp @@ -41,6 +41,8 @@ #include "FileItem.h" #include "settings/AdvancedSettings.h" #include "settings/GUISettings.h" +#include "settings/MediaSettings.h" +#include "settings/MediaSourceSettings.h" #include "settings/Settings.h" #include "utils/StringUtils.h" #include "guilib/LocalizeStrings.h" @@ -4089,7 +4091,7 @@ bool CVideoDatabase::UpdateOldVersion(int iVersion) if (iVersion < 50) { m_pDS->exec("ALTER TABLE settings ADD ScalingMethod integer"); - m_pDS->exec(PrepareSQL("UPDATE settings set ScalingMethod=%i", g_settings.m_defaultVideoSettings.m_ScalingMethod)); + m_pDS->exec(PrepareSQL("UPDATE settings set ScalingMethod=%i", CMediaSettings::Get().GetDefaultVideoSettings().m_ScalingMethod)); } if (iVersion < 51) { @@ -4808,7 +4810,7 @@ bool CVideoDatabase::GetNavCommon(const CStdString& strBaseDir, CFileItemList& i if (it == mapItems.end()) { // check path - if (g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv(2).get_asString()),g_settings.m_videoSources)) + if (g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv(2).get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { if (idContent == VIDEODB_CONTENT_MOVIES || idContent == VIDEODB_CONTENT_MUSICVIDEOS) mapItems.insert(pair<int, pair<CStdString,int> >(id, pair<CStdString,int>(str,m_pDS->fv(3).get_asInt()))); //fv(3) is file.playCount @@ -5072,7 +5074,7 @@ bool CVideoDatabase::GetMusicVideoAlbumsNav(const CStdString& strBaseDir, CFileI if (it == mapAlbums.end()) { // check path - if (g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),g_settings.m_videoSources)) + if (g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) mapAlbums.insert(make_pair(lidMVideo, make_pair(strAlbum,m_pDS->fv(2).get_asString()))); } m_pDS->next(); @@ -5304,7 +5306,7 @@ bool CVideoDatabase::GetPeopleNav(const CStdString& strBaseDir, CFileItemList& i if (it == mapActors.end()) { // check path - if (g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),g_settings.m_videoSources)) + if (g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) mapActors.insert(pair<int, CActor>(idActor, actor)); } m_pDS->next(); @@ -5455,7 +5457,7 @@ bool CVideoDatabase::GetYearsNav(const CStdString& strBaseDir, CFileItemList& it if (it == mapYears.end()) { // check path - if (g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),g_settings.m_videoSources)) + if (g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { CStdString year; year.Format("%d", lYear); @@ -5642,7 +5644,7 @@ bool CVideoDatabase::GetSeasonsNav(const CStdString& strBaseDir, CFileItemList& int iSeason = m_pDS->fv(0).get_asInt(); it = mapSeasons.find(iSeason); // check path - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),g_settings.m_videoSources)) + if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; @@ -5906,7 +5908,7 @@ bool CVideoDatabase::GetMoviesByWhere(const CStdString& strBaseDir, const Filter CVideoInfoTag movie = GetDetailsForMovie(record); if (g_settings.GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE || g_passwordManager.bMasterUser || - g_passwordManager.IsDatabasePathUnlocked(movie.m_strPath, g_settings.m_videoSources)) + g_passwordManager.IsDatabasePathUnlocked(movie.m_strPath, *CMediaSourceSettings::Get().GetSources("video"))) { CFileItemPtr pItem(new CFileItem(movie)); @@ -6011,7 +6013,7 @@ bool CVideoDatabase::GetTvShowsByWhere(const CStdString& strBaseDir, const Filte CVideoInfoTag movie = GetDetailsForTvShow(record, false); if ((g_settings.GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE || g_passwordManager.bMasterUser || - g_passwordManager.IsDatabasePathUnlocked(movie.m_strPath, g_settings.m_videoSources)) && + g_passwordManager.IsDatabasePathUnlocked(movie.m_strPath, *CMediaSourceSettings::Get().GetSources("video"))) && (!g_advancedSettings.m_bVideoLibraryHideEmptySeries || movie.m_iEpisode > 0)) { CFileItemPtr pItem(new CFileItem(movie)); @@ -6332,7 +6334,7 @@ bool CVideoDatabase::GetEpisodesByWhere(const CStdString& strBaseDir, const Filt CVideoInfoTag movie = GetDetailsForEpisode(record); if (g_settings.GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE || g_passwordManager.bMasterUser || - g_passwordManager.IsDatabasePathUnlocked(movie.m_strPath, g_settings.m_videoSources)) + g_passwordManager.IsDatabasePathUnlocked(movie.m_strPath, *CMediaSourceSettings::Get().GetSources("video"))) { CFileItemPtr pItem(new CFileItem(movie)); formatter.FormatLabel(pItem.get()); @@ -6773,7 +6775,7 @@ void CVideoDatabase::GetMovieGenresByName(const CStdString& strSearch, CFileItem { if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()), - g_settings.m_videoSources)) + *CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; @@ -6814,7 +6816,7 @@ void CVideoDatabase::GetMovieCountriesByName(const CStdString& strSearch, CFileI { if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()), - g_settings.m_videoSources)) + *CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; @@ -6854,7 +6856,7 @@ void CVideoDatabase::GetTvShowGenresByName(const CStdString& strSearch, CFileIte while (!m_pDS->eof()) { if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),g_settings.m_videoSources)) + if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; @@ -6894,7 +6896,7 @@ void CVideoDatabase::GetMovieActorsByName(const CStdString& strSearch, CFileItem while (!m_pDS->eof()) { if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),g_settings.m_videoSources)) + if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; @@ -6934,7 +6936,7 @@ void CVideoDatabase::GetTvShowsActorsByName(const CStdString& strSearch, CFileIt while (!m_pDS->eof()) { if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),g_settings.m_videoSources)) + if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; @@ -6977,7 +6979,7 @@ void CVideoDatabase::GetMusicVideoArtistsByName(const CStdString& strSearch, CFi while (!m_pDS->eof()) { if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),g_settings.m_videoSources)) + if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; @@ -7017,7 +7019,7 @@ void CVideoDatabase::GetMusicVideoGenresByName(const CStdString& strSearch, CFil while (!m_pDS->eof()) { if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),g_settings.m_videoSources)) + if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; @@ -7073,7 +7075,7 @@ void CVideoDatabase::GetMusicVideoAlbumsByName(const CStdString& strSearch, CFil } if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),g_settings.m_videoSources)) + if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; @@ -7113,7 +7115,7 @@ void CVideoDatabase::GetMusicVideosByAlbum(const CStdString& strSearch, CFileIte while (!m_pDS->eof()) { if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),g_settings.m_videoSources)) + if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; @@ -7192,7 +7194,7 @@ bool CVideoDatabase::GetMusicVideosByWhere(const CStdString &baseDir, const Filt CVideoInfoTag musicvideo = GetDetailsForMusicVideo(record); if (!checkLocks || g_settings.GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE || g_passwordManager.bMasterUser || - g_passwordManager.IsDatabasePathUnlocked(musicvideo.m_strPath, g_settings.m_videoSources)) + g_passwordManager.IsDatabasePathUnlocked(musicvideo.m_strPath, *CMediaSourceSettings::Get().GetSources("video"))) { CFileItemPtr item(new CFileItem(musicvideo)); @@ -7313,7 +7315,7 @@ int CVideoDatabase::GetMatchingMusicVideo(const CStdString& strArtist, const CSt return -1; if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),g_settings.m_videoSources)) + if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->close(); return -1; @@ -7348,7 +7350,7 @@ void CVideoDatabase::GetMoviesByName(const CStdString& strSearch, CFileItemList& while (!m_pDS->eof()) { if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),g_settings.m_videoSources)) + if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; @@ -7393,7 +7395,7 @@ void CVideoDatabase::GetTvShowsByName(const CStdString& strSearch, CFileItemList while (!m_pDS->eof()) { if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),g_settings.m_videoSources)) + if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; @@ -7435,7 +7437,7 @@ void CVideoDatabase::GetEpisodesByName(const CStdString& strSearch, CFileItemLis while (!m_pDS->eof()) { if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),g_settings.m_videoSources)) + if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; @@ -7478,7 +7480,7 @@ void CVideoDatabase::GetMusicVideosByName(const CStdString& strSearch, CFileItem while (!m_pDS->eof()) { if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),g_settings.m_videoSources)) + if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; @@ -7526,7 +7528,7 @@ void CVideoDatabase::GetEpisodesByPlot(const CStdString& strSearch, CFileItemLis while (!m_pDS->eof()) { if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),g_settings.m_videoSources)) + if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; @@ -7566,7 +7568,7 @@ void CVideoDatabase::GetMoviesByPlot(const CStdString& strSearch, CFileItemList& while (!m_pDS->eof()) { if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv(2).get_asString()),g_settings.m_videoSources)) + if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv(2).get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; @@ -7608,7 +7610,7 @@ void CVideoDatabase::GetMovieDirectorsByName(const CStdString& strSearch, CFileI while (!m_pDS->eof()) { if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),g_settings.m_videoSources)) + if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; @@ -7650,7 +7652,7 @@ void CVideoDatabase::GetTvShowsDirectorsByName(const CStdString& strSearch, CFil while (!m_pDS->eof()) { if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),g_settings.m_videoSources)) + if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; @@ -7692,7 +7694,7 @@ void CVideoDatabase::GetMusicVideoDirectorsByName(const CStdString& strSearch, C while (!m_pDS->eof()) { if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser) - if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),g_settings.m_videoSources)) + if (!g_passwordManager.IsDatabasePathUnlocked(CStdString(m_pDS->fv("path.strPath").get_asString()),*CMediaSourceSettings::Get().GetSources("video"))) { m_pDS->next(); continue; @@ -7784,7 +7786,7 @@ void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle, const se int current = 0; bool bIsSource; - VECSOURCES *pShares = g_settings.GetSourcesFromType("video"); + VECSOURCES *pShares = CMediaSourceSettings::Get().GetSources("video"); while (!m_pDS->eof()) { diff --git a/xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp b/xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp index 06ae29b13b..7b9396485d 100644 --- a/xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp +++ b/xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp @@ -34,6 +34,8 @@ #include "settings/AdvancedSettings.h" #include "settings/Settings.h" #include "settings/GUISettings.h" +#include "settings/MediaSettings.h" +#include "settings/MediaSourceSettings.h" #include "guilib/LocalizeStrings.h" #include "pvr/PVRManager.h" #include "cores/AudioEngine/Utils/AEUtil.h" @@ -86,20 +88,20 @@ void CGUIDialogAudioSubtitleSettings::CreateSettings() m_volume = g_settings.m_fVolumeLevel; AddSlider(AUDIO_SETTINGS_VOLUME, 13376, &m_volume, VOLUME_MINIMUM, VOLUME_MAXIMUM / 100.0f, VOLUME_MAXIMUM, PercentAsDecibel, false); if (SupportsAudioFeature(IPC_AUD_AMP)) - AddSlider(AUDIO_SETTINGS_VOLUME_AMPLIFICATION, 660, &g_settings.m_currentVideoSettings.m_VolumeAmplification, VOLUME_DRC_MINIMUM * 0.01f, (VOLUME_DRC_MAXIMUM - VOLUME_DRC_MINIMUM) / 6000.0f, VOLUME_DRC_MAXIMUM * 0.01f, FormatDecibel, false); + AddSlider(AUDIO_SETTINGS_VOLUME_AMPLIFICATION, 660, &CMediaSettings::Get().GetCurrentVideoSettings().m_VolumeAmplification, VOLUME_DRC_MINIMUM * 0.01f, (VOLUME_DRC_MAXIMUM - VOLUME_DRC_MINIMUM) / 6000.0f, VOLUME_DRC_MAXIMUM * 0.01f, FormatDecibel, false); if (g_application.m_pPlayer && g_application.m_pPlayer->IsPassthrough()) { EnableSettings(AUDIO_SETTINGS_VOLUME,false); EnableSettings(AUDIO_SETTINGS_VOLUME_AMPLIFICATION,false); } if (SupportsAudioFeature(IPC_AUD_OFFSET)) - AddSlider(AUDIO_SETTINGS_DELAY, 297, &g_settings.m_currentVideoSettings.m_AudioDelay, -g_advancedSettings.m_videoAudioDelayRange, .025f, g_advancedSettings.m_videoAudioDelayRange, FormatDelay); + AddSlider(AUDIO_SETTINGS_DELAY, 297, &CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay, -g_advancedSettings.m_videoAudioDelayRange, .025f, g_advancedSettings.m_videoAudioDelayRange, FormatDelay); if (SupportsAudioFeature(IPC_AUD_SELECT_STREAM)) AddAudioStreams(AUDIO_SETTINGS_STREAM); // only show stuff available in digital mode if we have digital output if (SupportsAudioFeature(IPC_AUD_OUTPUT_STEREO)) - AddBool(AUDIO_SETTINGS_OUTPUT_TO_ALL_SPEAKERS, 252, &g_settings.m_currentVideoSettings.m_OutputToAllSpeakers, AUDIO_IS_BITSTREAM(g_guiSettings.GetInt("audiooutput.mode"))); + AddBool(AUDIO_SETTINGS_OUTPUT_TO_ALL_SPEAKERS, 252, &CMediaSettings::Get().GetCurrentVideoSettings().m_OutputToAllSpeakers, AUDIO_IS_BITSTREAM(g_guiSettings.GetInt("audiooutput.mode"))); int settings[3] = { 338, 339, 420 }; //ANALOG, IEC958, HDMI m_outputmode = g_guiSettings.GetInt("audiooutput.mode"); @@ -110,7 +112,7 @@ void CGUIDialogAudioSubtitleSettings::CreateSettings() m_subtitleVisible = g_application.m_pPlayer->GetSubtitleVisible(); AddBool(SUBTITLE_SETTINGS_ENABLE, 13397, &m_subtitleVisible); if (SupportsSubtitleFeature(IPC_SUBS_OFFSET)) - AddSlider(SUBTITLE_SETTINGS_DELAY, 22006, &g_settings.m_currentVideoSettings.m_SubtitleDelay, -g_advancedSettings.m_videoSubsDelayRange, 0.1f, g_advancedSettings.m_videoSubsDelayRange, FormatDelay); + AddSlider(SUBTITLE_SETTINGS_DELAY, 22006, &CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay, -g_advancedSettings.m_videoSubsDelayRange, 0.1f, g_advancedSettings.m_videoSubsDelayRange, FormatDelay); if (SupportsSubtitleFeature(IPC_SUBS_SELECT)) AddSubtitleStreams(SUBTITLE_SETTINGS_STREAM); if (SupportsSubtitleFeature(IPC_SUBS_EXTERNAL)) @@ -145,14 +147,14 @@ void CGUIDialogAudioSubtitleSettings::AddAudioStreams(unsigned int id) bool bAC3 = strstr(strAudioCodec.c_str(), "AC3") != 0; if (iNumChannels == 2 && !(bDTS || bAC3)) { // ok, enable these options -/* if (g_settings.m_currentVideoSettings.m_AudioStream == -1) +/* if (CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream == -1) { // default to stereo stream - g_settings.m_currentVideoSettings.m_AudioStream = 0; + CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream = 0; }*/ setting.max = 2; for (int i = 0; i <= setting.max; i++) setting.entry.push_back(make_pair(setting.entry.size(), g_localizeStrings.Get(13320 + i))); - m_audioStream = -g_settings.m_currentVideoSettings.m_AudioStream - 1; + m_audioStream = -CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream - 1; m_settings.push_back(setting); return; } @@ -240,12 +242,12 @@ void CGUIDialogAudioSubtitleSettings::OnSettingChanged(SettingInfo &setting) else if (setting.id == AUDIO_SETTINGS_VOLUME_AMPLIFICATION) { if (g_application.m_pPlayer) - g_application.m_pPlayer->SetDynamicRangeCompression((long)(g_settings.m_currentVideoSettings.m_VolumeAmplification * 100)); + g_application.m_pPlayer->SetDynamicRangeCompression((long)(CMediaSettings::Get().GetCurrentVideoSettings().m_VolumeAmplification * 100)); } else if (setting.id == AUDIO_SETTINGS_DELAY) { if (g_application.m_pPlayer) - g_application.m_pPlayer->SetAVDelay(g_settings.m_currentVideoSettings.m_AudioDelay); + g_application.m_pPlayer->SetAVDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay); } else if (setting.id == AUDIO_SETTINGS_STREAM) { @@ -255,16 +257,16 @@ void CGUIDialogAudioSubtitleSettings::OnSettingChanged(SettingInfo &setting) if (setting.max == 2) { // we're in the case we want - call the code to switch channels etc. // update the screen setting... - g_settings.m_currentVideoSettings.m_AudioStream = -1 - m_audioStream; + CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream = -1 - m_audioStream; // call monkeyh1's code here... - //bool bAudioOnAllSpeakers = (g_guiSettings.GetInt("audiooutput.mode") == AUDIO_IEC958) && g_settings.m_currentVideoSettings.m_OutputToAllSpeakers; + //bool bAudioOnAllSpeakers = (g_guiSettings.GetInt("audiooutput.mode") == AUDIO_IEC958) && CMediaSettings::Get().GetCurrentVideoSettings().m_OutputToAllSpeakers; return; } } // only change the audio stream if a different one has been asked for if (g_application.m_pPlayer->GetAudioStream() != m_audioStream) { - g_settings.m_currentVideoSettings.m_AudioStream = m_audioStream; + CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream = m_audioStream; g_application.m_pPlayer->SetAudioStream(m_audioStream); // Set the audio stream to the one selected EnableSettings(AUDIO_SETTINGS_VOLUME, !g_application.m_pPlayer->IsPassthrough()); } @@ -290,16 +292,16 @@ void CGUIDialogAudioSubtitleSettings::OnSettingChanged(SettingInfo &setting) } else if (setting.id == SUBTITLE_SETTINGS_ENABLE) { - g_settings.m_currentVideoSettings.m_SubtitleOn = m_subtitleVisible; - g_application.m_pPlayer->SetSubtitleVisible(g_settings.m_currentVideoSettings.m_SubtitleOn); + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn = m_subtitleVisible; + g_application.m_pPlayer->SetSubtitleVisible(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn); } else if (setting.id == SUBTITLE_SETTINGS_DELAY) { - g_application.m_pPlayer->SetSubTitleDelay(g_settings.m_currentVideoSettings.m_SubtitleDelay); + g_application.m_pPlayer->SetSubTitleDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay); } else if (setting.id == SUBTITLE_SETTINGS_STREAM && setting.max > 0) { - g_settings.m_currentVideoSettings.m_SubtitleStream = m_subtitleStream; + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream = m_subtitleStream; g_application.m_pPlayer->SetSubtitle(m_subtitleStream); } else if (setting.id == SUBTITLE_SETTINGS_BROWSER) @@ -316,7 +318,7 @@ void CGUIDialogAudioSubtitleSettings::OnSettingChanged(SettingInfo &setting) CStdString strMask = ".utf|.utf8|.utf-8|.sub|.srt|.smi|.rt|.txt|.ssa|.aqt|.jss|.ass|.idx|.rar|.zip"; if (g_application.GetCurrentPlayer() == EPC_DVDPLAYER) strMask = ".srt|.rar|.zip|.ifo|.smi|.sub|.idx|.ass|.ssa|.txt"; - VECSOURCES shares(g_settings.m_videoSources); + VECSOURCES shares(*CMediaSourceSettings::Get().GetSources("video")); if (g_settings.iAdditionalSubtitleDirectoryChecked != -1 && !g_guiSettings.GetString("subtitles.custompath").IsEmpty()) { CMediaSource share; @@ -344,7 +346,7 @@ void CGUIDialogAudioSubtitleSettings::OnSettingChanged(SettingInfo &setting) g_application.m_pPlayer->SetSubtitle(m_subtitleStream); g_application.m_pPlayer->SetSubtitleVisible(true); } - g_settings.m_currentVideoSettings.m_SubtitleCached = true; + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleCached = true; Close(); } } @@ -362,9 +364,9 @@ void CGUIDialogAudioSubtitleSettings::OnSettingChanged(SettingInfo &setting) db.Open(); db.EraseVideoSettings(); db.Close(); - g_settings.m_defaultVideoSettings = g_settings.m_currentVideoSettings; - g_settings.m_defaultVideoSettings.m_SubtitleStream = -1; - g_settings.m_defaultVideoSettings.m_AudioStream = -1; + CMediaSettings::Get().GetDefaultVideoSettings() = CMediaSettings::Get().GetCurrentVideoSettings(); + CMediaSettings::Get().GetDefaultVideoSettings().m_SubtitleStream = -1; + CMediaSettings::Get().GetDefaultVideoSettings().m_AudioStream = -1; g_settings.Save(); } } diff --git a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp index 680f049637..633dc69f65 100644 --- a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp @@ -42,6 +42,7 @@ #include "settings/Settings.h" #include "settings/AdvancedSettings.h" #include "settings/GUISettings.h" +#include "settings/MediaSourceSettings.h" #include "guilib/Key.h" #include "guilib/LocalizeStrings.h" #include "GUIUserMessages.h" @@ -724,7 +725,7 @@ void CGUIDialogVideoInfo::OnGetArt() } CStdString result; - VECSOURCES sources(g_settings.m_videoSources); + VECSOURCES sources(*CMediaSourceSettings::Get().GetSources("video")); AddItemPathToFileBrowserSources(sources, *m_movieItem); g_mediaManager.GetLocalDrives(sources); if (CGUIDialogFileBrowser::ShowAndGetImage(items, sources, g_localizeStrings.Get(13511), result) && @@ -823,7 +824,7 @@ void CGUIDialogVideoInfo::OnGetFanart() } CStdString result; - VECSOURCES sources(g_settings.m_videoSources); + VECSOURCES sources(*CMediaSourceSettings::Get().GetSources("video")); AddItemPathToFileBrowserSources(sources, item); g_mediaManager.GetLocalDrives(sources); bool flip=false; diff --git a/xbmc/video/dialogs/GUIDialogVideoSettings.cpp b/xbmc/video/dialogs/GUIDialogVideoSettings.cpp index 5fa35c172f..ae73489b19 100644 --- a/xbmc/video/dialogs/GUIDialogVideoSettings.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoSettings.cpp @@ -30,6 +30,7 @@ #include "video/VideoDatabase.h" #include "dialogs/GUIDialogYesNo.h" #include "settings/Settings.h" +#include "settings/MediaSettings.h" #include "addons/Skin.h" #include "pvr/PVRManager.h" @@ -87,7 +88,7 @@ void CGUIDialogVideoSettings::CreateSettings() entries.push_back(make_pair(VS_DEINTERLACEMODE_FORCE , 16041)); if (entries.size()) - AddSpin(VIDEO_SETTINGS_DEINTERLACEMODE, 16037, (int*)&g_settings.m_currentVideoSettings.m_DeinterlaceMode, entries); + AddSpin(VIDEO_SETTINGS_DEINTERLACEMODE, 16037, (int*)&CMediaSettings::Get().GetCurrentVideoSettings().m_DeinterlaceMode, entries); } { vector<pair<int, int> > entries; @@ -122,8 +123,8 @@ void CGUIDialogVideoSettings::CreateSettings() if (entries.size() > 1) { - AddSpin(VIDEO_SETTINGS_INTERLACEMETHOD, 16038, (int*)&g_settings.m_currentVideoSettings.m_InterlaceMethod, entries); - if (g_settings.m_currentVideoSettings.m_DeinterlaceMode == VS_DEINTERLACEMODE_OFF) + AddSpin(VIDEO_SETTINGS_INTERLACEMETHOD, 16038, (int*)&CMediaSettings::Get().GetCurrentVideoSettings().m_InterlaceMethod, entries); + if (CMediaSettings::Get().GetCurrentVideoSettings().m_DeinterlaceMode == VS_DEINTERLACEMODE_OFF) EnableSettings(VIDEO_SETTINGS_INTERLACEMETHOD, false); } } @@ -155,37 +156,37 @@ void CGUIDialogVideoSettings::CreateSettings() it = entries.erase(it); } - AddSpin(VIDEO_SETTINGS_SCALINGMETHOD, 16300, (int*)&g_settings.m_currentVideoSettings.m_ScalingMethod, entries); + AddSpin(VIDEO_SETTINGS_SCALINGMETHOD, 16300, (int*)&CMediaSettings::Get().GetCurrentVideoSettings().m_ScalingMethod, entries); } if (g_renderManager.Supports(RENDERFEATURE_CROP)) - AddBool(VIDEO_SETTINGS_CROP, 644, &g_settings.m_currentVideoSettings.m_Crop); + AddBool(VIDEO_SETTINGS_CROP, 644, &CMediaSettings::Get().GetCurrentVideoSettings().m_Crop); if (g_renderManager.Supports(RENDERFEATURE_STRETCH) || g_renderManager.Supports(RENDERFEATURE_PIXEL_RATIO)) { const int entries[] = {630, 631, 632, 633, 634, 635, 636 }; - AddSpin(VIDEO_SETTINGS_VIEW_MODE, 629, &g_settings.m_currentVideoSettings.m_ViewMode, 7, entries); + AddSpin(VIDEO_SETTINGS_VIEW_MODE, 629, &CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode, 7, entries); } if (g_renderManager.Supports(RENDERFEATURE_ZOOM)) - AddSlider(VIDEO_SETTINGS_ZOOM, 216, &g_settings.m_currentVideoSettings.m_CustomZoomAmount, 0.5f, 0.01f, 2.0f, FormatFloat); + AddSlider(VIDEO_SETTINGS_ZOOM, 216, &CMediaSettings::Get().GetCurrentVideoSettings().m_CustomZoomAmount, 0.5f, 0.01f, 2.0f, FormatFloat); if (g_renderManager.Supports(RENDERFEATURE_VERTICAL_SHIFT)) - AddSlider(VIDEO_SETTINGS_VERTICAL_SHIFT, 225, &g_settings.m_currentVideoSettings.m_CustomVerticalShift, -2.0f, 0.01f, 2.0f, FormatFloat); + AddSlider(VIDEO_SETTINGS_VERTICAL_SHIFT, 225, &CMediaSettings::Get().GetCurrentVideoSettings().m_CustomVerticalShift, -2.0f, 0.01f, 2.0f, FormatFloat); if (g_renderManager.Supports(RENDERFEATURE_PIXEL_RATIO)) - AddSlider(VIDEO_SETTINGS_PIXEL_RATIO, 217, &g_settings.m_currentVideoSettings.m_CustomPixelRatio, 0.5f, 0.01f, 2.0f, FormatFloat); + AddSlider(VIDEO_SETTINGS_PIXEL_RATIO, 217, &CMediaSettings::Get().GetCurrentVideoSettings().m_CustomPixelRatio, 0.5f, 0.01f, 2.0f, FormatFloat); if (g_renderManager.Supports(RENDERFEATURE_POSTPROCESS)) - AddBool(VIDEO_SETTINGS_POSTPROCESS, 16400, &g_settings.m_currentVideoSettings.m_PostProcess); + AddBool(VIDEO_SETTINGS_POSTPROCESS, 16400, &CMediaSettings::Get().GetCurrentVideoSettings().m_PostProcess); #ifdef HAS_VIDEO_PLAYBACK if (g_renderManager.Supports(RENDERFEATURE_BRIGHTNESS)) - AddSlider(VIDEO_SETTINGS_BRIGHTNESS, 464, &g_settings.m_currentVideoSettings.m_Brightness, 0, 1, 100, FormatInteger); + AddSlider(VIDEO_SETTINGS_BRIGHTNESS, 464, &CMediaSettings::Get().GetCurrentVideoSettings().m_Brightness, 0, 1, 100, FormatInteger); if (g_renderManager.Supports(RENDERFEATURE_CONTRAST)) - AddSlider(VIDEO_SETTINGS_CONTRAST, 465, &g_settings.m_currentVideoSettings.m_Contrast, 0, 1, 100, FormatInteger); + AddSlider(VIDEO_SETTINGS_CONTRAST, 465, &CMediaSettings::Get().GetCurrentVideoSettings().m_Contrast, 0, 1, 100, FormatInteger); if (g_renderManager.Supports(RENDERFEATURE_GAMMA)) - AddSlider(VIDEO_SETTINGS_GAMMA, 466, &g_settings.m_currentVideoSettings.m_Gamma, 0, 1, 100, FormatInteger); + AddSlider(VIDEO_SETTINGS_GAMMA, 466, &CMediaSettings::Get().GetCurrentVideoSettings().m_Gamma, 0, 1, 100, FormatInteger); if (g_renderManager.Supports(RENDERFEATURE_NOISE)) - AddSlider(VIDEO_SETTING_VDPAU_NOISE, 16312, &g_settings.m_currentVideoSettings.m_NoiseReduction, 0.0f, 0.01f, 1.0f, FormatFloat); + AddSlider(VIDEO_SETTING_VDPAU_NOISE, 16312, &CMediaSettings::Get().GetCurrentVideoSettings().m_NoiseReduction, 0.0f, 0.01f, 1.0f, FormatFloat); if (g_renderManager.Supports(RENDERFEATURE_SHARPNESS)) - AddSlider(VIDEO_SETTING_VDPAU_SHARPNESS, 16313, &g_settings.m_currentVideoSettings.m_Sharpness, -1.0f, 0.02f, 1.0f, FormatFloat); + AddSlider(VIDEO_SETTING_VDPAU_SHARPNESS, 16313, &CMediaSettings::Get().GetCurrentVideoSettings().m_Sharpness, -1.0f, 0.02f, 1.0f, FormatFloat); if (g_renderManager.Supports(RENDERFEATURE_NONLINSTRETCH)) - AddBool(VIDEO_SETTINGS_NONLIN_STRETCH, 659, &g_settings.m_currentVideoSettings.m_CustomNonLinStretch); + AddBool(VIDEO_SETTINGS_NONLIN_STRETCH, 659, &CMediaSettings::Get().GetCurrentVideoSettings().m_CustomNonLinStretch); #endif AddSeparator(8); AddButton(VIDEO_SETTINGS_MAKE_DEFAULT, 12376); @@ -202,7 +203,7 @@ void CGUIDialogVideoSettings::OnSettingChanged(SettingInfo &setting) } else if (setting.id == VIDEO_SETTINGS_VIEW_MODE) { - g_renderManager.SetViewMode(g_settings.m_currentVideoSettings.m_ViewMode); + g_renderManager.SetViewMode(CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode); UpdateSetting(VIDEO_SETTINGS_ZOOM); UpdateSetting(VIDEO_SETTINGS_PIXEL_RATIO); UpdateSetting(VIDEO_SETTINGS_NONLIN_STRETCH); @@ -212,8 +213,8 @@ void CGUIDialogVideoSettings::OnSettingChanged(SettingInfo &setting) || setting.id == VIDEO_SETTINGS_NONLIN_STRETCH || setting.id == VIDEO_SETTINGS_VERTICAL_SHIFT) { - g_settings.m_currentVideoSettings.m_ViewMode = VIEW_MODE_CUSTOM; - g_renderManager.SetViewMode(VIEW_MODE_CUSTOM); + CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode = ViewModeCustom; + g_renderManager.SetViewMode(ViewModeCustom); UpdateSetting(VIDEO_SETTINGS_VIEW_MODE); } else @@ -239,15 +240,15 @@ void CGUIDialogVideoSettings::OnSettingChanged(SettingInfo &setting) db.Open(); db.EraseVideoSettings(); db.Close(); - g_settings.m_defaultVideoSettings = g_settings.m_currentVideoSettings; - g_settings.m_defaultVideoSettings.m_SubtitleStream = -1; - g_settings.m_defaultVideoSettings.m_AudioStream = -1; + CMediaSettings::Get().GetDefaultVideoSettings() = CMediaSettings::Get().GetCurrentVideoSettings(); + CMediaSettings::Get().GetDefaultVideoSettings().m_SubtitleStream = -1; + CMediaSettings::Get().GetDefaultVideoSettings().m_AudioStream = -1; g_settings.Save(); } } else if (setting.id == VIDEO_SETTINGS_DEINTERLACEMODE) { - EnableSettings(VIDEO_SETTINGS_INTERLACEMETHOD, g_settings.m_currentVideoSettings.m_DeinterlaceMode != VS_DEINTERLACEMODE_OFF); + EnableSettings(VIDEO_SETTINGS_INTERLACEMETHOD, CMediaSettings::Get().GetCurrentVideoSettings().m_DeinterlaceMode != VS_DEINTERLACEMODE_OFF); } if (g_PVRManager.IsPlayingRadio() || g_PVRManager.IsPlayingTV()) diff --git a/xbmc/video/windows/GUIWindowFullScreen.cpp b/xbmc/video/windows/GUIWindowFullScreen.cpp index c1d33dbb7b..0d26a97f1c 100644 --- a/xbmc/video/windows/GUIWindowFullScreen.cpp +++ b/xbmc/video/windows/GUIWindowFullScreen.cpp @@ -42,6 +42,7 @@ #include "dialogs/GUIDialogKaiToast.h" #include "guilib/GUISliderControl.h" #include "settings/Settings.h" +#include "settings/MediaSettings.h" #include "guilib/GUISelectButtonControl.h" #include "FileItem.h" #include "video/VideoReferenceClock.h" @@ -223,10 +224,10 @@ bool CGUIWindowFullScreen::OnAction(const CAction &action) if (g_application.m_pPlayer->GetSubtitleCount() == 0) return true; - g_settings.m_currentVideoSettings.m_SubtitleOn = !g_settings.m_currentVideoSettings.m_SubtitleOn; - g_application.m_pPlayer->SetSubtitleVisible(g_settings.m_currentVideoSettings.m_SubtitleOn); + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn = !CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn; + g_application.m_pPlayer->SetSubtitleVisible(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn); CStdString sub, lang; - if (g_settings.m_currentVideoSettings.m_SubtitleOn) + if (CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn) { SPlayerSubtitleStreamInfo info; g_application.m_pPlayer->GetSubtitleStreamInfo(g_application.m_pPlayer->GetSubtitle(), info); @@ -259,28 +260,28 @@ bool CGUIWindowFullScreen::OnAction(const CAction &action) if (g_application.m_pPlayer->GetSubtitleCount() == 0) return true; - if(g_settings.m_currentVideoSettings.m_SubtitleStream < 0) - g_settings.m_currentVideoSettings.m_SubtitleStream = g_application.m_pPlayer->GetSubtitle(); + if(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream < 0) + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream = g_application.m_pPlayer->GetSubtitle(); - if (g_settings.m_currentVideoSettings.m_SubtitleOn) + if (CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn) { - g_settings.m_currentVideoSettings.m_SubtitleStream++; - if (g_settings.m_currentVideoSettings.m_SubtitleStream >= g_application.m_pPlayer->GetSubtitleCount()) + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream++; + if (CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream >= g_application.m_pPlayer->GetSubtitleCount()) { - g_settings.m_currentVideoSettings.m_SubtitleStream = 0; - g_settings.m_currentVideoSettings.m_SubtitleOn = false; + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream = 0; + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn = false; g_application.m_pPlayer->SetSubtitleVisible(false); } - g_application.m_pPlayer->SetSubtitle(g_settings.m_currentVideoSettings.m_SubtitleStream); + g_application.m_pPlayer->SetSubtitle(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream); } else { - g_settings.m_currentVideoSettings.m_SubtitleOn = true; + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn = true; g_application.m_pPlayer->SetSubtitleVisible(true); } CStdString sub, lang; - if (g_settings.m_currentVideoSettings.m_SubtitleOn) + if (CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn) { SPlayerSubtitleStreamInfo info; g_application.m_pPlayer->GetSubtitleStreamInfo(g_application.m_pPlayer->GetSubtitle(), info); @@ -296,61 +297,61 @@ bool CGUIWindowFullScreen::OnAction(const CAction &action) break; case ACTION_SUBTITLE_DELAY_MIN: - g_settings.m_currentVideoSettings.m_SubtitleDelay -= 0.1f; - if (g_settings.m_currentVideoSettings.m_SubtitleDelay < -g_advancedSettings.m_videoSubsDelayRange) - g_settings.m_currentVideoSettings.m_SubtitleDelay = -g_advancedSettings.m_videoSubsDelayRange; + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay -= 0.1f; + if (CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay < -g_advancedSettings.m_videoSubsDelayRange) + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay = -g_advancedSettings.m_videoSubsDelayRange; if (g_application.m_pPlayer) - g_application.m_pPlayer->SetSubTitleDelay(g_settings.m_currentVideoSettings.m_SubtitleDelay); + g_application.m_pPlayer->SetSubTitleDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay); - ShowSlider(action.GetID(), 22006, g_settings.m_currentVideoSettings.m_SubtitleDelay, + ShowSlider(action.GetID(), 22006, CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay, -g_advancedSettings.m_videoSubsDelayRange, 0.1f, g_advancedSettings.m_videoSubsDelayRange); return true; break; case ACTION_SUBTITLE_DELAY_PLUS: - g_settings.m_currentVideoSettings.m_SubtitleDelay += 0.1f; - if (g_settings.m_currentVideoSettings.m_SubtitleDelay > g_advancedSettings.m_videoSubsDelayRange) - g_settings.m_currentVideoSettings.m_SubtitleDelay = g_advancedSettings.m_videoSubsDelayRange; + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay += 0.1f; + if (CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay > g_advancedSettings.m_videoSubsDelayRange) + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay = g_advancedSettings.m_videoSubsDelayRange; if (g_application.m_pPlayer) - g_application.m_pPlayer->SetSubTitleDelay(g_settings.m_currentVideoSettings.m_SubtitleDelay); + g_application.m_pPlayer->SetSubTitleDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay); - ShowSlider(action.GetID(), 22006, g_settings.m_currentVideoSettings.m_SubtitleDelay, + ShowSlider(action.GetID(), 22006, CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay, -g_advancedSettings.m_videoSubsDelayRange, 0.1f, g_advancedSettings.m_videoSubsDelayRange); return true; break; case ACTION_SUBTITLE_DELAY: - ShowSlider(action.GetID(), 22006, g_settings.m_currentVideoSettings.m_SubtitleDelay, + ShowSlider(action.GetID(), 22006, CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay, -g_advancedSettings.m_videoSubsDelayRange, 0.1f, g_advancedSettings.m_videoSubsDelayRange, true); return true; break; case ACTION_AUDIO_DELAY: - ShowSlider(action.GetID(), 297, g_settings.m_currentVideoSettings.m_AudioDelay, + ShowSlider(action.GetID(), 297, CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay, -g_advancedSettings.m_videoAudioDelayRange, 0.025f, g_advancedSettings.m_videoAudioDelayRange, true); return true; break; case ACTION_AUDIO_DELAY_MIN: - g_settings.m_currentVideoSettings.m_AudioDelay -= 0.025f; - if (g_settings.m_currentVideoSettings.m_AudioDelay < -g_advancedSettings.m_videoAudioDelayRange) - g_settings.m_currentVideoSettings.m_AudioDelay = -g_advancedSettings.m_videoAudioDelayRange; + CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay -= 0.025f; + if (CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay < -g_advancedSettings.m_videoAudioDelayRange) + CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay = -g_advancedSettings.m_videoAudioDelayRange; if (g_application.m_pPlayer) - g_application.m_pPlayer->SetAVDelay(g_settings.m_currentVideoSettings.m_AudioDelay); + g_application.m_pPlayer->SetAVDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay); - ShowSlider(action.GetID(), 297, g_settings.m_currentVideoSettings.m_AudioDelay, + ShowSlider(action.GetID(), 297, CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay, -g_advancedSettings.m_videoAudioDelayRange, 0.025f, g_advancedSettings.m_videoAudioDelayRange); return true; break; case ACTION_AUDIO_DELAY_PLUS: - g_settings.m_currentVideoSettings.m_AudioDelay += 0.025f; - if (g_settings.m_currentVideoSettings.m_AudioDelay > g_advancedSettings.m_videoAudioDelayRange) - g_settings.m_currentVideoSettings.m_AudioDelay = g_advancedSettings.m_videoAudioDelayRange; + CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay += 0.025f; + if (CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay > g_advancedSettings.m_videoAudioDelayRange) + CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay = g_advancedSettings.m_videoAudioDelayRange; if (g_application.m_pPlayer) - g_application.m_pPlayer->SetAVDelay(g_settings.m_currentVideoSettings.m_AudioDelay); + g_application.m_pPlayer->SetAVDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay); - ShowSlider(action.GetID(), 297, g_settings.m_currentVideoSettings.m_AudioDelay, + ShowSlider(action.GetID(), 297, CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay, -g_advancedSettings.m_videoAudioDelayRange, 0.025f, g_advancedSettings.m_videoAudioDelayRange); return true; @@ -360,16 +361,16 @@ bool CGUIWindowFullScreen::OnAction(const CAction &action) if (g_application.m_pPlayer->GetAudioStreamCount() == 1) return true; - if(g_settings.m_currentVideoSettings.m_AudioStream < 0) - g_settings.m_currentVideoSettings.m_AudioStream = g_application.m_pPlayer->GetAudioStream(); + if(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream < 0) + CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream = g_application.m_pPlayer->GetAudioStream(); - g_settings.m_currentVideoSettings.m_AudioStream++; - if (g_settings.m_currentVideoSettings.m_AudioStream >= g_application.m_pPlayer->GetAudioStreamCount()) - g_settings.m_currentVideoSettings.m_AudioStream = 0; - g_application.m_pPlayer->SetAudioStream(g_settings.m_currentVideoSettings.m_AudioStream); // Set the audio stream to the one selected + CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream++; + if (CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream >= g_application.m_pPlayer->GetAudioStreamCount()) + CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream = 0; + g_application.m_pPlayer->SetAudioStream(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream); // Set the audio stream to the one selected CStdString aud; SPlayerAudioStreamInfo info; - g_application.m_pPlayer->GetAudioStreamInfo(g_settings.m_currentVideoSettings.m_AudioStream, info); + g_application.m_pPlayer->GetAudioStreamInfo(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream, info); aud = info.name; CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(460), aud, DisplTime, false, MsgTime); return true; @@ -432,7 +433,7 @@ bool CGUIWindowFullScreen::OnAction(const CAction &action) if (m_bShowViewModeInfo) { #ifdef HAS_VIDEO_PLAYBACK - g_renderManager.SetViewMode(++g_settings.m_currentVideoSettings.m_ViewMode); + g_renderManager.SetViewMode(++CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode); #endif } m_bShowViewModeInfo = true; @@ -466,67 +467,67 @@ bool CGUIWindowFullScreen::OnAction(const CAction &action) break; case ACTION_ZOOM_IN: { - g_settings.m_currentVideoSettings.m_CustomZoomAmount += 0.01f; - if (g_settings.m_currentVideoSettings.m_CustomZoomAmount > 2.f) - g_settings.m_currentVideoSettings.m_CustomZoomAmount = 2.f; - g_settings.m_currentVideoSettings.m_ViewMode = VIEW_MODE_CUSTOM; - g_renderManager.SetViewMode(VIEW_MODE_CUSTOM); - ShowSlider(action.GetID(), 216, g_settings.m_currentVideoSettings.m_CustomZoomAmount, 0.5f, 0.1f, 2.0f); + CMediaSettings::Get().GetCurrentVideoSettings().m_CustomZoomAmount += 0.01f; + if (CMediaSettings::Get().GetCurrentVideoSettings().m_CustomZoomAmount > 2.f) + CMediaSettings::Get().GetCurrentVideoSettings().m_CustomZoomAmount = 2.f; + CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode = ViewModeCustom; + g_renderManager.SetViewMode(ViewModeCustom); + ShowSlider(action.GetID(), 216, CMediaSettings::Get().GetCurrentVideoSettings().m_CustomZoomAmount, 0.5f, 0.1f, 2.0f); } return true; break; case ACTION_ZOOM_OUT: { - g_settings.m_currentVideoSettings.m_CustomZoomAmount -= 0.01f; - if (g_settings.m_currentVideoSettings.m_CustomZoomAmount < 0.5f) - g_settings.m_currentVideoSettings.m_CustomZoomAmount = 0.5f; - g_settings.m_currentVideoSettings.m_ViewMode = VIEW_MODE_CUSTOM; - g_renderManager.SetViewMode(VIEW_MODE_CUSTOM); - ShowSlider(action.GetID(), 216, g_settings.m_currentVideoSettings.m_CustomZoomAmount, 0.5f, 0.1f, 2.0f); + CMediaSettings::Get().GetCurrentVideoSettings().m_CustomZoomAmount -= 0.01f; + if (CMediaSettings::Get().GetCurrentVideoSettings().m_CustomZoomAmount < 0.5f) + CMediaSettings::Get().GetCurrentVideoSettings().m_CustomZoomAmount = 0.5f; + CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode = ViewModeCustom; + g_renderManager.SetViewMode(ViewModeCustom); + ShowSlider(action.GetID(), 216, CMediaSettings::Get().GetCurrentVideoSettings().m_CustomZoomAmount, 0.5f, 0.1f, 2.0f); } return true; break; case ACTION_INCREASE_PAR: { - g_settings.m_currentVideoSettings.m_CustomPixelRatio += 0.01f; - if (g_settings.m_currentVideoSettings.m_CustomPixelRatio > 2.f) - g_settings.m_currentVideoSettings.m_CustomZoomAmount = 2.f; - g_settings.m_currentVideoSettings.m_ViewMode = VIEW_MODE_CUSTOM; - g_renderManager.SetViewMode(VIEW_MODE_CUSTOM); - ShowSlider(action.GetID(), 217, g_settings.m_currentVideoSettings.m_CustomPixelRatio, 0.5f, 0.1f, 2.0f); + CMediaSettings::Get().GetCurrentVideoSettings().m_CustomPixelRatio += 0.01f; + if (CMediaSettings::Get().GetCurrentVideoSettings().m_CustomPixelRatio > 2.f) + CMediaSettings::Get().GetCurrentVideoSettings().m_CustomZoomAmount = 2.f; + CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode = ViewModeCustom; + g_renderManager.SetViewMode(ViewModeCustom); + ShowSlider(action.GetID(), 217, CMediaSettings::Get().GetCurrentVideoSettings().m_CustomPixelRatio, 0.5f, 0.1f, 2.0f); } return true; break; case ACTION_DECREASE_PAR: { - g_settings.m_currentVideoSettings.m_CustomPixelRatio -= 0.01f; - if (g_settings.m_currentVideoSettings.m_CustomZoomAmount < 0.5f) - g_settings.m_currentVideoSettings.m_CustomPixelRatio = 0.5f; - g_settings.m_currentVideoSettings.m_ViewMode = VIEW_MODE_CUSTOM; - g_renderManager.SetViewMode(VIEW_MODE_CUSTOM); - ShowSlider(action.GetID(), 217, g_settings.m_currentVideoSettings.m_CustomPixelRatio, 0.5f, 0.1f, 2.0f); + CMediaSettings::Get().GetCurrentVideoSettings().m_CustomPixelRatio -= 0.01f; + if (CMediaSettings::Get().GetCurrentVideoSettings().m_CustomZoomAmount < 0.5f) + CMediaSettings::Get().GetCurrentVideoSettings().m_CustomPixelRatio = 0.5f; + CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode = ViewModeCustom; + g_renderManager.SetViewMode(ViewModeCustom); + ShowSlider(action.GetID(), 217, CMediaSettings::Get().GetCurrentVideoSettings().m_CustomPixelRatio, 0.5f, 0.1f, 2.0f); } return true; break; case ACTION_VSHIFT_UP: { - g_settings.m_currentVideoSettings.m_CustomVerticalShift -= 0.01f; - if (g_settings.m_currentVideoSettings.m_CustomVerticalShift < -2.0f) - g_settings.m_currentVideoSettings.m_CustomVerticalShift = -2.0f; - g_settings.m_currentVideoSettings.m_ViewMode = VIEW_MODE_CUSTOM; - g_renderManager.SetViewMode(VIEW_MODE_CUSTOM); - ShowSlider(action.GetID(), 225, g_settings.m_currentVideoSettings.m_CustomVerticalShift, -2.0f, 0.1f, 2.0f); + CMediaSettings::Get().GetCurrentVideoSettings().m_CustomVerticalShift -= 0.01f; + if (CMediaSettings::Get().GetCurrentVideoSettings().m_CustomVerticalShift < -2.0f) + CMediaSettings::Get().GetCurrentVideoSettings().m_CustomVerticalShift = -2.0f; + CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode = ViewModeCustom; + g_renderManager.SetViewMode(ViewModeCustom); + ShowSlider(action.GetID(), 225, CMediaSettings::Get().GetCurrentVideoSettings().m_CustomVerticalShift, -2.0f, 0.1f, 2.0f); } return true; break; case ACTION_VSHIFT_DOWN: { - g_settings.m_currentVideoSettings.m_CustomVerticalShift += 0.01f; - if (g_settings.m_currentVideoSettings.m_CustomVerticalShift > 2.0f) - g_settings.m_currentVideoSettings.m_CustomVerticalShift = 2.0f; - g_settings.m_currentVideoSettings.m_ViewMode = VIEW_MODE_CUSTOM; - g_renderManager.SetViewMode(VIEW_MODE_CUSTOM); - ShowSlider(action.GetID(), 225, g_settings.m_currentVideoSettings.m_CustomVerticalShift, -2.0f, 0.1f, 2.0f); + CMediaSettings::Get().GetCurrentVideoSettings().m_CustomVerticalShift += 0.01f; + if (CMediaSettings::Get().GetCurrentVideoSettings().m_CustomVerticalShift > 2.0f) + CMediaSettings::Get().GetCurrentVideoSettings().m_CustomVerticalShift = 2.0f; + CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode = ViewModeCustom; + g_renderManager.SetViewMode(ViewModeCustom); + ShowSlider(action.GetID(), 225, CMediaSettings::Get().GetCurrentVideoSettings().m_CustomVerticalShift, -2.0f, 0.1f, 2.0f); } return true; break; @@ -608,17 +609,17 @@ bool CGUIWindowFullScreen::OnAction(const CAction &action) float sliderMin = VOLUME_DRC_MINIMUM / 100.0f; if (action.GetID() == ACTION_VOLAMP_UP) - g_settings.m_currentVideoSettings.m_VolumeAmplification += 1.0f; + CMediaSettings::Get().GetCurrentVideoSettings().m_VolumeAmplification += 1.0f; else - g_settings.m_currentVideoSettings.m_VolumeAmplification -= 1.0f; + CMediaSettings::Get().GetCurrentVideoSettings().m_VolumeAmplification -= 1.0f; - g_settings.m_currentVideoSettings.m_VolumeAmplification = - std::max(std::min(g_settings.m_currentVideoSettings.m_VolumeAmplification, sliderMax), sliderMin); + CMediaSettings::Get().GetCurrentVideoSettings().m_VolumeAmplification = + std::max(std::min(CMediaSettings::Get().GetCurrentVideoSettings().m_VolumeAmplification, sliderMax), sliderMin); if (g_application.m_pPlayer) - g_application.m_pPlayer->SetDynamicRangeCompression((long)(g_settings.m_currentVideoSettings.m_VolumeAmplification * 100)); + g_application.m_pPlayer->SetDynamicRangeCompression((long)(CMediaSettings::Get().GetCurrentVideoSettings().m_VolumeAmplification * 100)); - ShowSlider(action.GetID(), 660, g_settings.m_currentVideoSettings.m_VolumeAmplification, sliderMin, 1.0f, sliderMax); + ShowSlider(action.GetID(), 660, CMediaSettings::Get().GetCurrentVideoSettings().m_VolumeAmplification, sliderMin, 1.0f, sliderMax); break; } @@ -947,7 +948,7 @@ void CGUIWindowFullScreen::FrameMove() { // get the "View Mode" string CStdString strTitle = g_localizeStrings.Get(629); - CStdString strMode = g_localizeStrings.Get(630 + g_settings.m_currentVideoSettings.m_ViewMode); + CStdString strMode = g_localizeStrings.Get(630 + CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode); CStdString strInfo; strInfo.Format("%s : %s", strTitle.c_str(), strMode.c_str()); CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW1); @@ -1236,13 +1237,13 @@ void CGUIWindowFullScreen::OnSliderChange(void *data, CGUISliderControl *slider) { if (m_sliderAction == ACTION_AUDIO_DELAY) { - g_settings.m_currentVideoSettings.m_AudioDelay = slider->GetFloatValue(); - g_application.m_pPlayer->SetAVDelay(g_settings.m_currentVideoSettings.m_AudioDelay); + CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay = slider->GetFloatValue(); + g_application.m_pPlayer->SetAVDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay); } else if (m_sliderAction == ACTION_SUBTITLE_DELAY) { - g_settings.m_currentVideoSettings.m_SubtitleDelay = slider->GetFloatValue(); - g_application.m_pPlayer->SetSubTitleDelay(g_settings.m_currentVideoSettings.m_SubtitleDelay); + CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay = slider->GetFloatValue(); + g_application.m_pPlayer->SetSubTitleDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay); } } } diff --git a/xbmc/video/windows/GUIWindowVideoBase.cpp b/xbmc/video/windows/GUIWindowVideoBase.cpp index b1376612e1..9030a7b1c8 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.cpp +++ b/xbmc/video/windows/GUIWindowVideoBase.cpp @@ -55,6 +55,7 @@ #include "settings/Settings.h" #include "settings/AdvancedSettings.h" #include "settings/GUISettings.h" +#include "settings/MediaSettings.h" #include "settings/dialogs/GUIDialogContentSettings.h" #include "guilib/Key.h" #include "guilib/LocalizeStrings.h" @@ -782,9 +783,9 @@ void CGUIWindowVideoBase::AddItemToPlayList(const CFileItemPtr &pItem, CFileItem GetDirectory(pItem->GetPath(), items); FormatAndSort(items); - int watchedMode = g_settings.GetWatchMode(items.GetContent()); - bool unwatchedOnly = watchedMode == VIDEO_SHOW_UNWATCHED; - bool watchedOnly = watchedMode == VIDEO_SHOW_WATCHED; + int watchedMode = CMediaSettings::Get().GetWatchedMode(items.GetContent()); + bool unwatchedOnly = watchedMode == WatchedModeUnwatched; + bool watchedOnly = watchedMode == WatchedModeWatched; for (int i = 0; i < items.Size(); ++i) { if (items[i]->m_bIsFolder) diff --git a/xbmc/video/windows/GUIWindowVideoNav.cpp b/xbmc/video/windows/GUIWindowVideoNav.cpp index 9c04164bdb..50981c5c7b 100644 --- a/xbmc/video/windows/GUIWindowVideoNav.cpp +++ b/xbmc/video/windows/GUIWindowVideoNav.cpp @@ -44,6 +44,8 @@ #include "settings/Settings.h" #include "settings/AdvancedSettings.h" #include "settings/GUISettings.h" +#include "settings/MediaSettings.h" +#include "settings/MediaSourceSettings.h" #include "guilib/Key.h" #include "guilib/LocalizeStrings.h" #include "storage/MediaManager.h" @@ -120,7 +122,7 @@ bool CGUIWindowVideoNav::OnMessage(CGUIMessage& message) SetProperty("flattened", g_settings.m_bMyVideoNavFlatten); if (message.GetNumStringParams() && message.GetStringParam(0).Equals("Files") && - g_settings.GetSourcesFromType("video")->empty()) + CMediaSourceSettings::Get().GetSources("video")->empty()) { message.SetStringParam(""); } @@ -161,7 +163,7 @@ bool CGUIWindowVideoNav::OnMessage(CGUIMessage& message) } else if (iControl == CONTROL_BTNSHOWMODE) { - g_settings.CycleWatchMode(m_vecItems->GetContent()); + CMediaSettings::Get().CycleWatchedMode(m_vecItems->GetContent()); g_settings.Save(); OnFilterItems(GetProperty("filter").asString()); return true; @@ -178,10 +180,10 @@ bool CGUIWindowVideoNav::OnMessage(CGUIMessage& message) } else if (iControl == CONTROL_BTNSHOWALL) { - if (g_settings.GetWatchMode(m_vecItems->GetContent()) == VIDEO_SHOW_ALL) - g_settings.SetWatchMode(m_vecItems->GetContent(), VIDEO_SHOW_UNWATCHED); + if (CMediaSettings::Get().GetWatchedMode(m_vecItems->GetContent()) == WatchedModeAll) + CMediaSettings::Get().SetWatchedMode(m_vecItems->GetContent(), WatchedModeUnwatched); else - g_settings.SetWatchMode(m_vecItems->GetContent(), VIDEO_SHOW_ALL); + CMediaSettings::Get().SetWatchedMode(m_vecItems->GetContent(), WatchedModeAll); g_settings.Save(); OnFilterItems(GetProperty("filter").asString()); return true; @@ -371,7 +373,7 @@ bool CGUIWindowVideoNav::GetDirectory(const CStdString &strDirectory, CFileItemL else if (!items.IsVirtualDirectoryRoot()) { // load info from the database CStdString label; - if (items.GetLabel().IsEmpty() && m_rootDir.IsSource(items.GetPath(), g_settings.GetSourcesFromType("video"), &label)) + if (items.GetLabel().IsEmpty() && m_rootDir.IsSource(items.GetPath(), CMediaSourceSettings::Get().GetSources("video"), &label)) items.SetLabel(label); if (!items.IsSourcesPath()) LoadVideoInfo(items); @@ -533,10 +535,10 @@ void CGUIWindowVideoNav::UpdateButtons() SET_CONTROL_LABEL(CONTROL_FILTER, strLabel); - int watchMode = g_settings.GetWatchMode(m_vecItems->GetContent()); + int watchMode = CMediaSettings::Get().GetWatchedMode(m_vecItems->GetContent()); SET_CONTROL_LABEL(CONTROL_BTNSHOWMODE, g_localizeStrings.Get(16100 + watchMode)); - SET_CONTROL_SELECTED(GetID(), CONTROL_BTNSHOWALL, watchMode != VIDEO_SHOW_ALL); + SET_CONTROL_SELECTED(GetID(), CONTROL_BTNSHOWALL, watchMode != WatchedModeAll); SET_CONTROL_SELECTED(GetID(),CONTROL_BTNPARTYMODE, g_partyModeManager.IsEnabled()); @@ -1215,7 +1217,7 @@ bool CGUIWindowVideoNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) if (!local) items.Add(noneitem); - VECSOURCES sources=g_settings.m_videoSources; + VECSOURCES sources=*CMediaSourceSettings::Get().GetSources("video"); g_mediaManager.GetLocalDrives(sources); CStdString result; CGUIDialogVideoInfo::AddItemPathToFileBrowserSources(sources, *item); @@ -1414,7 +1416,7 @@ void CGUIWindowVideoNav::OnChooseFanart(const CFileItem &videoItem) } CStdString result; - VECSOURCES sources(g_settings.m_videoSources); + VECSOURCES sources(*CMediaSourceSettings::Get().GetSources("video")); g_mediaManager.GetLocalDrives(sources); CGUIDialogVideoInfo::AddItemPathToFileBrowserSources(sources, item); bool flip=false; @@ -1654,7 +1656,7 @@ bool CGUIWindowVideoNav::ApplyWatchedFilter(CFileItemList &items) (items.IsSmartPlayList() || (items.HasProperty("library.filter") && items.GetProperty("library.filter").asBoolean()))) node = NODE_TYPE_TITLE_TVSHOWS; // so that the check below works - int watchMode = g_settings.GetWatchMode(m_vecItems->GetContent()); + int watchMode = CMediaSettings::Get().GetWatchedMode(m_vecItems->GetContent()); for (int i = 0; i < items.Size(); i++) { @@ -1662,11 +1664,11 @@ bool CGUIWindowVideoNav::ApplyWatchedFilter(CFileItemList &items) if(item->HasVideoInfoTag() && (node == NODE_TYPE_TITLE_TVSHOWS || node == NODE_TYPE_SEASONS)) { - if (watchMode == VIDEO_SHOW_UNWATCHED) + if (watchMode == WatchedModeUnwatched) item->GetVideoInfoTag()->m_iEpisode = (int)item->GetProperty("unwatchedepisodes").asInteger(); - if (watchMode == VIDEO_SHOW_WATCHED) + if (watchMode == WatchedModeWatched) item->GetVideoInfoTag()->m_iEpisode = (int)item->GetProperty("watchedepisodes").asInteger(); - if (watchMode == VIDEO_SHOW_ALL) + if (watchMode == WatchedModeAll) item->GetVideoInfoTag()->m_iEpisode = (int)item->GetProperty("totalepisodes").asInteger(); item->SetProperty("numepisodes", item->GetVideoInfoTag()->m_iEpisode); listchanged = true; @@ -1674,8 +1676,8 @@ bool CGUIWindowVideoNav::ApplyWatchedFilter(CFileItemList &items) if (filterWatched) { - if((watchMode==VIDEO_SHOW_WATCHED && item->GetVideoInfoTag()->m_playCount== 0) - || (watchMode==VIDEO_SHOW_UNWATCHED && item->GetVideoInfoTag()->m_playCount > 0)) + if((watchMode==WatchedModeWatched && item->GetVideoInfoTag()->m_playCount== 0) + || (watchMode==WatchedModeUnwatched && item->GetVideoInfoTag()->m_playCount > 0)) { items.Remove(i); i--; diff --git a/xbmc/view/GUIViewState.cpp b/xbmc/view/GUIViewState.cpp index 6778263893..864e448a10 100644 --- a/xbmc/view/GUIViewState.cpp +++ b/xbmc/view/GUIViewState.cpp @@ -38,6 +38,7 @@ #include "view/ViewState.h" #include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" +#include "settings/MediaSourceSettings.h" #include "settings/Settings.h" #include "FileItem.h" #include "guilib/Key.h" @@ -405,7 +406,7 @@ void CGUIViewState::AddAndroidSource(const CStdString &content, const CStdString void CGUIViewState::AddLiveTVSources() { - VECSOURCES *sources = g_settings.GetSourcesFromType("video"); + VECSOURCES *sources = CMediaSourceSettings::Get().GetSources("video"); for (IVECSOURCES it = sources->begin(); it != sources->end(); it++) { if (URIUtils::IsLiveTV((*it).strPath)) diff --git a/xbmc/view/Makefile b/xbmc/view/Makefile index 2afefa4689..3b35a25f0b 100644 --- a/xbmc/view/Makefile +++ b/xbmc/view/Makefile @@ -1,6 +1,7 @@ SRCS=GUIViewControl.cpp \ GUIViewState.cpp \ ViewDatabase.cpp \ + ViewStateSettings.cpp \ LIB=view.a diff --git a/xbmc/view/ViewStateSettings.cpp b/xbmc/view/ViewStateSettings.cpp new file mode 100644 index 0000000000..0df7b8c290 --- /dev/null +++ b/xbmc/view/ViewStateSettings.cpp @@ -0,0 +1,165 @@ +/* + * 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 <string.h> + +#include "ViewStateSettings.h" +#include "threads/SingleLock.h" +#include "utils/log.h" +#include "utils/StringUtils.h" +#include "utils/XBMCTinyXML.h" +#include "utils/XMLUtils.h" + +#define XML_VIEWSTATESETTINGS "viewstates" +#define XML_VIEWMODE "viewmode" +#define XML_SORTMETHOD "sortmethod" +#define XML_SORTORDER "sortorder" + +using namespace std; + +CViewStateSettings::CViewStateSettings() +{ + AddViewState("musicnavartists"); + AddViewState("musicnavalbums"); + AddViewState("musicnavsongs"); + AddViewState("musiclastfm"); + AddViewState("videonavactors"); + AddViewState("videonavyears"); + AddViewState("videonavgenres"); + AddViewState("videonavtitles"); + AddViewState("videonavepisodes", DEFAULT_VIEW_AUTO, SORT_METHOD_EPISODE); + AddViewState("videonavtvshows"); + AddViewState("videonavseasons"); + AddViewState("videonavmusicvideos"); + + AddViewState("programs", DEFAULT_VIEW_AUTO); + AddViewState("pictures", DEFAULT_VIEW_AUTO); + AddViewState("videofiles", DEFAULT_VIEW_AUTO); + AddViewState("musicfiles", DEFAULT_VIEW_AUTO); +} + +CViewStateSettings::~CViewStateSettings() +{ + for (map<string, CViewState*>::const_iterator viewState = m_viewStates.begin(); viewState != m_viewStates.end(); viewState++) + delete viewState->second; + m_viewStates.clear(); +} + +CViewStateSettings& CViewStateSettings::Get() +{ + static CViewStateSettings sViewStateSettings; + return sViewStateSettings; +} + +bool CViewStateSettings::Load(const TiXmlNode *settings) +{ + if (settings == NULL) + return false; + + CSingleLock lock(m_critical); + const TiXmlNode *pElement = settings->FirstChildElement(XML_VIEWSTATESETTINGS); + if (pElement == NULL) + { + CLog::Log(LOGWARNING, "CViewStateSettings: no <viewstates> tag found"); + return false; + } + + for (map<string, CViewState*>::iterator viewState = m_viewStates.begin(); viewState != m_viewStates.end(); viewState++) + { + const TiXmlNode* pViewState = pElement->FirstChildElement(viewState->first); + if (pViewState == NULL) + continue; + + XMLUtils::GetInt(pViewState, XML_VIEWMODE, viewState->second->m_viewMode, DEFAULT_VIEW_LIST, DEFAULT_VIEW_MAX); + + int sortMethod; + if (XMLUtils::GetInt(pViewState, XML_SORTMETHOD, sortMethod, SORT_METHOD_NONE, SORT_METHOD_MAX)) + viewState->second->m_sortMethod = (SORT_METHOD)sortMethod; + + int sortOrder; + if (XMLUtils::GetInt(pViewState, XML_SORTORDER, sortOrder, SortOrderNone, SortOrderDescending)) + viewState->second->m_sortOrder = (SortOrder)sortOrder; + } + + return true; +} + +bool CViewStateSettings::Save(TiXmlNode *settings) const +{ + if (settings == NULL) + return false; + + CSingleLock lock(m_critical); + // add the <viewstates> tag + TiXmlElement xmlViewStateElement(XML_VIEWSTATESETTINGS); + TiXmlNode *pViewStateNode = settings->InsertEndChild(xmlViewStateElement); + if (pViewStateNode == NULL) + { + CLog::Log(LOGWARNING, "CViewStateSettings: could not create <viewstates> tag"); + return false; + } + + for (map<string, CViewState*>::const_iterator viewState = m_viewStates.begin(); viewState != m_viewStates.end(); viewState++) + { + TiXmlElement newElement(viewState->first); + TiXmlNode *pNewNode = pViewStateNode->InsertEndChild(newElement); + if (pNewNode == NULL) + continue; + + XMLUtils::SetInt(pNewNode, XML_VIEWMODE, viewState->second->m_viewMode); + XMLUtils::SetInt(pNewNode, XML_SORTMETHOD, (int)viewState->second->m_sortMethod); + XMLUtils::SetInt(pNewNode, XML_SORTORDER, (int)viewState->second->m_sortOrder); + + } + + return true; +} + +const CViewState* CViewStateSettings::Get(const std::string &viewState) const +{ + CSingleLock lock(m_critical); + map<string, CViewState*>::const_iterator view = m_viewStates.find(viewState); + if (view != m_viewStates.end()) + return view->second; + + return NULL; +} + +CViewState* CViewStateSettings::Get(const std::string &viewState) +{ + CSingleLock lock(m_critical); + map<string, CViewState*>::iterator view = m_viewStates.find(viewState); + if (view != m_viewStates.end()) + return view->second; + + return NULL; +} + +void CViewStateSettings::AddViewState(const std::string& strTagName, int defaultView /* = DEFAULT_VIEW_LIST */, SORT_METHOD defaultSort /* = SORT_METHOD_LABEL */) +{ + if (strTagName.empty() || m_viewStates.find(strTagName) != m_viewStates.end()) + return; + + CViewState *viewState = new CViewState(defaultView, defaultSort, SortOrderAscending); + if (viewState == NULL) + return; + + m_viewStates.insert(make_pair(strTagName, viewState)); +} diff --git a/xbmc/view/ViewStateSettings.h b/xbmc/view/ViewStateSettings.h new file mode 100644 index 0000000000..b2174a571a --- /dev/null +++ b/xbmc/view/ViewStateSettings.h @@ -0,0 +1,54 @@ +#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 <map> +#include <string> + +#include "ViewState.h" +#include "guilib/GraphicContext.h" +#include "settings/ISubSettings.h" +#include "threads/CriticalSection.h" + +class TiXmlNode; + +class CViewStateSettings : public ISubSettings +{ +public: + static CViewStateSettings& Get(); + + virtual bool Load(const TiXmlNode *settings); + virtual bool Save(TiXmlNode *settings) const; + + const CViewState* Get(const std::string &viewState) const; + CViewState* Get(const std::string &viewState); + +protected: + CViewStateSettings(); + CViewStateSettings(const CViewStateSettings&); + CViewStateSettings const& operator=(CViewStateSettings const&); + virtual ~CViewStateSettings(); + +private: + std::map<std::string, CViewState*> m_viewStates; + CCriticalSection m_critical; + + void AddViewState(const std::string& strTagName, int defaultView = DEFAULT_VIEW_LIST, SORT_METHOD defaultSort = SORT_METHOD_LABEL); +}; diff --git a/xbmc/windows/GUIWindowFileManager.cpp b/xbmc/windows/GUIWindowFileManager.cpp index aa6548565e..b750e9ce99 100644 --- a/xbmc/windows/GUIWindowFileManager.cpp +++ b/xbmc/windows/GUIWindowFileManager.cpp @@ -50,6 +50,7 @@ #include "settings/Settings.h" #include "settings/AdvancedSettings.h" #include "settings/GUISettings.h" +#include "settings/MediaSourceSettings.h" #include "input/MouseStat.h" #include "guilib/LocalizeStrings.h" #include "utils/StringUtils.h" @@ -565,7 +566,7 @@ void CGUIWindowFileManager::OnClick(int iList, int iItem) { if (CGUIDialogMediaSource::ShowAndAddMediaSource("files")) { - m_rootDir.SetSources(g_settings.m_fileSources); + m_rootDir.SetSources(*CMediaSourceSettings::Get().GetSources("files")); Update(0,m_Directory[0]->GetPath()); Update(1,m_Directory[1]->GetPath()); } @@ -984,7 +985,7 @@ void CGUIWindowFileManager::OnPopupMenu(int list, int item, bool bContextDriven // and do the popup menu if (CGUIDialogContextMenu::SourcesMenu("files", pItem, posX, posY)) { - m_rootDir.SetSources(g_settings.m_fileSources); + m_rootDir.SetSources(*CMediaSourceSettings::Get().GetSources("files")); if (m_Directory[1 - list]->IsVirtualDirectoryRoot()) Refresh(); else @@ -1148,7 +1149,7 @@ int64_t CGUIWindowFileManager::CalculateFolderSize(const CStdString &strDirector int64_t totalSize = 0; CFileItemList items; CVirtualDirectory rootDir; - rootDir.SetSources(g_settings.m_fileSources); + rootDir.SetSources(*CMediaSourceSettings::Get().GetSources("files")); rootDir.GetDirectory(strDirectory, items, false); for (int i=0; i < items.Size(); i++) { @@ -1227,7 +1228,7 @@ void CGUIWindowFileManager::SetInitialPath(const CStdString &path) { // check for a passed destination path CStdString strDestination = path; - m_rootDir.SetSources(*g_settings.GetSourcesFromType("files")); + m_rootDir.SetSources(*CMediaSourceSettings::Get().GetSources("files")); if (!strDestination.IsEmpty()) { CLog::Log(LOGINFO, "Attempting to quickpath to: %s", strDestination.c_str()); @@ -1235,7 +1236,7 @@ void CGUIWindowFileManager::SetInitialPath(const CStdString &path) // otherwise, is this the first time accessing this window? else if (m_Directory[0]->GetPath() == "?") { - m_Directory[0]->SetPath(strDestination = g_settings.m_defaultFileSource); + m_Directory[0]->SetPath(strDestination = CMediaSourceSettings::Get().GetDefaultSource("files")); CLog::Log(LOGINFO, "Attempting to default to: %s", strDestination.c_str()); } // try to open the destination path diff --git a/xbmc/windows/GUIWindowLoginScreen.cpp b/xbmc/windows/GUIWindowLoginScreen.cpp index ca40758df5..780a8905ad 100644 --- a/xbmc/windows/GUIWindowLoginScreen.cpp +++ b/xbmc/windows/GUIWindowLoginScreen.cpp @@ -47,6 +47,7 @@ #include "guilib/Key.h" #include "guilib/LocalizeStrings.h" #include "addons/AddonManager.h" +#include "view/ViewState.h" #define CONTROL_BIG_LIST 52 #define CONTROL_LABEL_HEADER 2 |