diff --git a/XBMC-ATV2.xcodeproj/project.pbxproj b/XBMC-ATV2.xcodeproj/project.pbxproj index 576285a57dd8d..7076f68159104 100644 --- a/XBMC-ATV2.xcodeproj/project.pbxproj +++ b/XBMC-ATV2.xcodeproj/project.pbxproj @@ -259,6 +259,21 @@ DFDB004A1516408F005079A4 /* DirectoryCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFDB00431516408F005079A4 /* DirectoryCache.cpp */; }; DFDB004B1516408F005079A4 /* FileCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFDB00451516408F005079A4 /* FileCache.cpp */; }; DFDB004C1516408F005079A4 /* MemBufferCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFDB00471516408F005079A4 /* MemBufferCache.cpp */; }; + DFECFB69172D9E2B00A43CF7 /* GUIControlSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB67172D9E2B00A43CF7 /* GUIControlSettings.cpp */; }; + DFECFB84172D9E4C00A43CF7 /* ISetting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB6A172D9E4C00A43CF7 /* ISetting.cpp */; }; + DFECFB85172D9E4C00A43CF7 /* Setting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB6E172D9E4C00A43CF7 /* Setting.cpp */; }; + DFECFB86172D9E4C00A43CF7 /* SettingAddon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB70172D9E4C00A43CF7 /* SettingAddon.cpp */; }; + DFECFB87172D9E4C00A43CF7 /* SettingCategoryAccess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB72172D9E4C00A43CF7 /* SettingCategoryAccess.cpp */; }; + DFECFB88172D9E4C00A43CF7 /* SettingConditions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB74172D9E4C00A43CF7 /* SettingConditions.cpp */; }; + DFECFB89172D9E4C00A43CF7 /* SettingControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB76172D9E4C00A43CF7 /* SettingControl.cpp */; }; + DFECFB8A172D9E4C00A43CF7 /* SettingDependency.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB78172D9E4C00A43CF7 /* SettingDependency.cpp */; }; + DFECFB8B172D9E4C00A43CF7 /* SettingPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB7A172D9E4C00A43CF7 /* SettingPath.cpp */; }; + DFECFB8C172D9E4C00A43CF7 /* SettingSection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB7C172D9E4C00A43CF7 /* SettingSection.cpp */; }; + DFECFB8D172D9E4C00A43CF7 /* SettingsManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB7E172D9E4C00A43CF7 /* SettingsManager.cpp */; }; + DFECFB8E172D9E4C00A43CF7 /* SettingUpdate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB80172D9E4C00A43CF7 /* SettingUpdate.cpp */; }; + DFECFB8F172D9E4C00A43CF7 /* SettingVisibility.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB82172D9E4C00A43CF7 /* SettingVisibility.cpp */; }; + DFECFB92172D9E6D00A43CF7 /* BooleanLogic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB90172D9E6D00A43CF7 /* BooleanLogic.cpp */; }; + DFECFBFD172DA58800A43CF7 /* NetworkServices.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFBFB172DA58800A43CF7 /* NetworkServices.cpp */; }; DFFD594F1506B6300088DE4B /* IOSEAGLView.mm in Sources */ = {isa = PBXBuildFile; fileRef = DFFD594C1506B6300088DE4B /* IOSEAGLView.mm */; }; DFFEFBDB151606CB001294DC /* IOSScreenManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = DFFEFBDA151606CB001294DC /* IOSScreenManager.mm */; }; DFFEFC2215160927001294DC /* IOSExternalTouchController.mm in Sources */ = {isa = PBXBuildFile; fileRef = DFFEFC2115160927001294DC /* IOSExternalTouchController.mm */; }; @@ -268,7 +283,6 @@ F563530316E5442F00D21BAD /* UPnPSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F563530116E5442F00D21BAD /* UPnPSettings.cpp */; }; F563530F16E5446300D21BAD /* GUIDialogContentSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F563530716E5446300D21BAD /* GUIDialogContentSettings.cpp */; }; F563531216E5446300D21BAD /* GUIDialogSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F563530D16E5446300D21BAD /* GUIDialogSettings.cpp */; }; - F563531F16E5446C00D21BAD /* GUISettingControls.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F563531316E5446C00D21BAD /* GUISettingControls.cpp */; }; F563532016E5446C00D21BAD /* GUIWindowSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F563531516E5446C00D21BAD /* GUIWindowSettings.cpp */; }; F563532116E5446C00D21BAD /* GUIWindowSettingsCategory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F563531716E5446C00D21BAD /* GUIWindowSettingsCategory.cpp */; }; F563532316E5446C00D21BAD /* GUIWindowSettingsScreenCalibration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F563531B16E5446C00D21BAD /* GUIWindowSettingsScreenCalibration.cpp */; }; @@ -771,7 +785,6 @@ F56C7AED131EC155000AD0F6 /* GUIViewStatePrograms.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C76B5131EC153000AD0F6 /* GUIViewStatePrograms.cpp */; }; F56C7AEE131EC155000AD0F6 /* GUIWindowPrograms.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C76B7131EC153000AD0F6 /* GUIWindowPrograms.cpp */; }; F56C7AF3131EC155000AD0F6 /* RenderSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C76C3131EC153000AD0F6 /* RenderSystem.cpp */; }; - F56C7AF9131EC155000AD0F6 /* GUISettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C76D1131EC153000AD0F6 /* GUISettings.cpp */; }; F56C7AFA131EC155000AD0F6 /* AdvancedSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C76D3131EC153000AD0F6 /* AdvancedSettings.cpp */; }; F56C7B00131EC155000AD0F6 /* Settings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C76DF131EC153000AD0F6 /* Settings.cpp */; }; F56C7B02131EC155000AD0F6 /* VideoSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C76E3131EC153000AD0F6 /* VideoSettings.cpp */; }; @@ -1550,6 +1563,38 @@ DFDB00461516408F005079A4 /* FileCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileCache.h; sourceTree = ""; }; DFDB00471516408F005079A4 /* MemBufferCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemBufferCache.cpp; sourceTree = ""; }; DFDB00481516408F005079A4 /* MemBufferCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemBufferCache.h; sourceTree = ""; }; + DFECFB67172D9E2B00A43CF7 /* GUIControlSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GUIControlSettings.cpp; path = windows/GUIControlSettings.cpp; sourceTree = ""; }; + DFECFB68172D9E2B00A43CF7 /* GUIControlSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GUIControlSettings.h; path = windows/GUIControlSettings.h; sourceTree = ""; }; + DFECFB6A172D9E4C00A43CF7 /* ISetting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ISetting.cpp; sourceTree = ""; }; + DFECFB6B172D9E4C00A43CF7 /* ISetting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISetting.h; sourceTree = ""; }; + DFECFB6C172D9E4C00A43CF7 /* ISettingCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISettingCallback.h; sourceTree = ""; }; + DFECFB6D172D9E4C00A43CF7 /* ISettingCreator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISettingCreator.h; sourceTree = ""; }; + DFECFB6E172D9E4C00A43CF7 /* Setting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Setting.cpp; sourceTree = ""; }; + DFECFB6F172D9E4C00A43CF7 /* Setting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Setting.h; sourceTree = ""; }; + DFECFB70172D9E4C00A43CF7 /* SettingAddon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingAddon.cpp; sourceTree = ""; }; + DFECFB71172D9E4C00A43CF7 /* SettingAddon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingAddon.h; sourceTree = ""; }; + DFECFB72172D9E4C00A43CF7 /* SettingCategoryAccess.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingCategoryAccess.cpp; sourceTree = ""; }; + DFECFB73172D9E4C00A43CF7 /* SettingCategoryAccess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingCategoryAccess.h; sourceTree = ""; }; + DFECFB74172D9E4C00A43CF7 /* SettingConditions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingConditions.cpp; sourceTree = ""; }; + DFECFB75172D9E4C00A43CF7 /* SettingConditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingConditions.h; sourceTree = ""; }; + DFECFB76172D9E4C00A43CF7 /* SettingControl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingControl.cpp; sourceTree = ""; }; + DFECFB77172D9E4C00A43CF7 /* SettingControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingControl.h; sourceTree = ""; }; + DFECFB78172D9E4C00A43CF7 /* SettingDependency.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingDependency.cpp; sourceTree = ""; }; + DFECFB79172D9E4C00A43CF7 /* SettingDependency.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingDependency.h; sourceTree = ""; }; + DFECFB7A172D9E4C00A43CF7 /* SettingPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingPath.cpp; sourceTree = ""; }; + DFECFB7B172D9E4C00A43CF7 /* SettingPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingPath.h; sourceTree = ""; }; + DFECFB7C172D9E4C00A43CF7 /* SettingSection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingSection.cpp; sourceTree = ""; }; + DFECFB7D172D9E4C00A43CF7 /* SettingSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingSection.h; sourceTree = ""; }; + DFECFB7E172D9E4C00A43CF7 /* SettingsManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingsManager.cpp; sourceTree = ""; }; + DFECFB7F172D9E4C00A43CF7 /* SettingsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsManager.h; sourceTree = ""; }; + DFECFB80172D9E4C00A43CF7 /* SettingUpdate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingUpdate.cpp; sourceTree = ""; }; + DFECFB81172D9E4C00A43CF7 /* SettingUpdate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingUpdate.h; sourceTree = ""; }; + DFECFB82172D9E4C00A43CF7 /* SettingVisibility.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingVisibility.cpp; sourceTree = ""; }; + DFECFB83172D9E4C00A43CF7 /* SettingVisibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingVisibility.h; sourceTree = ""; }; + DFECFB90172D9E6D00A43CF7 /* BooleanLogic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BooleanLogic.cpp; sourceTree = ""; }; + DFECFB91172D9E6D00A43CF7 /* BooleanLogic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BooleanLogic.h; sourceTree = ""; }; + DFECFBFB172DA58800A43CF7 /* NetworkServices.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkServices.cpp; sourceTree = ""; }; + DFECFBFC172DA58800A43CF7 /* NetworkServices.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkServices.h; sourceTree = ""; }; DFFD594B1506B6300088DE4B /* IOSEAGLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IOSEAGLView.h; sourceTree = ""; }; DFFD594C1506B6300088DE4B /* IOSEAGLView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IOSEAGLView.mm; sourceTree = ""; }; DFFEFBD9151606CB001294DC /* IOSScreenManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IOSScreenManager.h; sourceTree = ""; }; @@ -1579,8 +1624,6 @@ F563530816E5446300D21BAD /* GUIDialogContentSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GUIDialogContentSettings.h; path = dialogs/GUIDialogContentSettings.h; sourceTree = ""; }; F563530D16E5446300D21BAD /* GUIDialogSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GUIDialogSettings.cpp; path = dialogs/GUIDialogSettings.cpp; sourceTree = ""; }; F563530E16E5446300D21BAD /* GUIDialogSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GUIDialogSettings.h; path = dialogs/GUIDialogSettings.h; sourceTree = ""; }; - F563531316E5446C00D21BAD /* GUISettingControls.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GUISettingControls.cpp; path = windows/GUISettingControls.cpp; sourceTree = ""; }; - F563531416E5446C00D21BAD /* GUISettingControls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GUISettingControls.h; path = windows/GUISettingControls.h; sourceTree = ""; }; F563531516E5446C00D21BAD /* GUIWindowSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GUIWindowSettings.cpp; path = windows/GUIWindowSettings.cpp; sourceTree = ""; }; F563531616E5446C00D21BAD /* GUIWindowSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GUIWindowSettings.h; path = windows/GUIWindowSettings.h; sourceTree = ""; }; F563531716E5446C00D21BAD /* GUIWindowSettingsCategory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GUIWindowSettingsCategory.cpp; path = windows/GUIWindowSettingsCategory.cpp; sourceTree = ""; }; @@ -2701,8 +2744,6 @@ F56C76B8131EC153000AD0F6 /* GUIWindowPrograms.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIWindowPrograms.h; sourceTree = ""; }; F56C76C3131EC153000AD0F6 /* RenderSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSystem.cpp; sourceTree = ""; }; F56C76C4131EC153000AD0F6 /* RenderSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSystem.h; sourceTree = ""; }; - F56C76D1131EC153000AD0F6 /* GUISettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GUISettings.cpp; sourceTree = ""; }; - F56C76D2131EC153000AD0F6 /* GUISettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUISettings.h; sourceTree = ""; }; F56C76D3131EC153000AD0F6 /* AdvancedSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AdvancedSettings.cpp; sourceTree = ""; }; F56C76D4131EC153000AD0F6 /* AdvancedSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdvancedSettings.h; sourceTree = ""; }; F56C76DF131EC153000AD0F6 /* Settings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Settings.cpp; sourceTree = ""; }; @@ -3791,8 +3832,8 @@ F563530616E5444500D21BAD /* windows */ = { isa = PBXGroup; children = ( - F563531316E5446C00D21BAD /* GUISettingControls.cpp */, - F563531416E5446C00D21BAD /* GUISettingControls.h */, + DFECFB67172D9E2B00A43CF7 /* GUIControlSettings.cpp */, + DFECFB68172D9E2B00A43CF7 /* GUIControlSettings.h */, F563531516E5446C00D21BAD /* GUIWindowSettings.cpp */, F563531616E5446C00D21BAD /* GUIWindowSettings.h */, F563531716E5446C00D21BAD /* GUIWindowSettingsCategory.cpp */, @@ -5494,6 +5535,8 @@ F56C7662131EC153000AD0F6 /* GUIDialogNetworkSetup.h */, F56C7663131EC153000AD0F6 /* Network.cpp */, F56C7664131EC153000AD0F6 /* Network.h */, + DFECFBFB172DA58800A43CF7 /* NetworkServices.cpp */, + DFECFBFC172DA58800A43CF7 /* NetworkServices.h */, F56C7665131EC153000AD0F6 /* Socket.cpp */, F56C7666131EC153000AD0F6 /* Socket.h */, F56C7667131EC153000AD0F6 /* TCPServer.cpp */, @@ -5661,16 +5704,40 @@ F56C76D4131EC153000AD0F6 /* AdvancedSettings.h */, DF28EE14170E1E8D005FA9D2 /* DisplaySettings.cpp */, DF28EE15170E1E8D005FA9D2 /* DisplaySettings.h */, - F56C76D1131EC153000AD0F6 /* GUISettings.cpp */, - F56C76D2131EC153000AD0F6 /* GUISettings.h */, + DFECFB6A172D9E4C00A43CF7 /* ISetting.cpp */, + DFECFB6B172D9E4C00A43CF7 /* ISetting.h */, + DFECFB6C172D9E4C00A43CF7 /* ISettingCallback.h */, + DFECFB6D172D9E4C00A43CF7 /* ISettingCreator.h */, DF898FFC1709B95B00B35C21 /* ISettingsHandler.h */, DF898FFD1709B95B00B35C21 /* ISubSettings.h */, DF898FFE1709B95B00B35C21 /* MediaSettings.cpp */, DF898FFF1709B95B00B35C21 /* MediaSettings.h */, DF8990001709B95B00B35C21 /* MediaSourceSettings.cpp */, DF8990011709B95B00B35C21 /* MediaSourceSettings.h */, + DFECFB6E172D9E4C00A43CF7 /* Setting.cpp */, + DFECFB6F172D9E4C00A43CF7 /* Setting.h */, + DFECFB70172D9E4C00A43CF7 /* SettingAddon.cpp */, + DFECFB71172D9E4C00A43CF7 /* SettingAddon.h */, + DFECFB72172D9E4C00A43CF7 /* SettingCategoryAccess.cpp */, + DFECFB73172D9E4C00A43CF7 /* SettingCategoryAccess.h */, + DFECFB74172D9E4C00A43CF7 /* SettingConditions.cpp */, + DFECFB75172D9E4C00A43CF7 /* SettingConditions.h */, + DFECFB76172D9E4C00A43CF7 /* SettingControl.cpp */, + DFECFB77172D9E4C00A43CF7 /* SettingControl.h */, + DFECFB78172D9E4C00A43CF7 /* SettingDependency.cpp */, + DFECFB79172D9E4C00A43CF7 /* SettingDependency.h */, + DFECFB7A172D9E4C00A43CF7 /* SettingPath.cpp */, + DFECFB7B172D9E4C00A43CF7 /* SettingPath.h */, F56C76DF131EC153000AD0F6 /* Settings.cpp */, F56C76E0131EC153000AD0F6 /* Settings.h */, + DFECFB7C172D9E4C00A43CF7 /* SettingSection.cpp */, + DFECFB7D172D9E4C00A43CF7 /* SettingSection.h */, + DFECFB7E172D9E4C00A43CF7 /* SettingsManager.cpp */, + DFECFB7F172D9E4C00A43CF7 /* SettingsManager.h */, + DFECFB80172D9E4C00A43CF7 /* SettingUpdate.cpp */, + DFECFB81172D9E4C00A43CF7 /* SettingUpdate.h */, + DFECFB82172D9E4C00A43CF7 /* SettingVisibility.cpp */, + DFECFB83172D9E4C00A43CF7 /* SettingVisibility.h */, DF8990021709B95B00B35C21 /* SkinSettings.cpp */, DF8990031709B95B00B35C21 /* SkinSettings.h */, F56C76E3131EC153000AD0F6 /* VideoSettings.cpp */, @@ -5749,6 +5816,8 @@ DF527785151BAFEE00B5B63B /* Base64.h */, F56C7727131EC154000AD0F6 /* BitstreamStats.cpp */, F56C7728131EC154000AD0F6 /* BitstreamStats.h */, + DFECFB90172D9E6D00A43CF7 /* BooleanLogic.cpp */, + DFECFB91172D9E6D00A43CF7 /* BooleanLogic.h */, F56C7729131EC154000AD0F6 /* CharsetConverter.cpp */, F56C772A131EC154000AD0F6 /* CharsetConverter.h */, F56C772B131EC154000AD0F6 /* CPUInfo.cpp */, @@ -7182,7 +7251,6 @@ F56C7AED131EC155000AD0F6 /* GUIViewStatePrograms.cpp in Sources */, F56C7AEE131EC155000AD0F6 /* GUIWindowPrograms.cpp in Sources */, F56C7AF3131EC155000AD0F6 /* RenderSystem.cpp in Sources */, - F56C7AF9131EC155000AD0F6 /* GUISettings.cpp in Sources */, F56C7AFA131EC155000AD0F6 /* AdvancedSettings.cpp in Sources */, F56C7B00131EC155000AD0F6 /* Settings.cpp in Sources */, F56C7B02131EC155000AD0F6 /* VideoSettings.cpp in Sources */, @@ -7665,7 +7733,6 @@ F563530316E5442F00D21BAD /* UPnPSettings.cpp in Sources */, F563530F16E5446300D21BAD /* GUIDialogContentSettings.cpp in Sources */, F563531216E5446300D21BAD /* GUIDialogSettings.cpp in Sources */, - F563531F16E5446C00D21BAD /* GUISettingControls.cpp in Sources */, F563532016E5446C00D21BAD /* GUIWindowSettings.cpp in Sources */, F563532116E5446C00D21BAD /* GUIWindowSettingsCategory.cpp in Sources */, F563532316E5446C00D21BAD /* GUIWindowSettingsScreenCalibration.cpp in Sources */, @@ -7685,6 +7752,21 @@ 7C87B2EE162CE3F400EF897D /* PlayerController.cpp in Sources */, F52CC6481713ADE900113454 /* DirectoryNodeGrouped.cpp in Sources */, F52CC6D51713BE0D00113454 /* DirectoryNodeGrouped.cpp in Sources */, + DFECFB69172D9E2B00A43CF7 /* GUIControlSettings.cpp in Sources */, + DFECFB84172D9E4C00A43CF7 /* ISetting.cpp in Sources */, + DFECFB85172D9E4C00A43CF7 /* Setting.cpp in Sources */, + DFECFB86172D9E4C00A43CF7 /* SettingAddon.cpp in Sources */, + DFECFB87172D9E4C00A43CF7 /* SettingCategoryAccess.cpp in Sources */, + DFECFB88172D9E4C00A43CF7 /* SettingConditions.cpp in Sources */, + DFECFB89172D9E4C00A43CF7 /* SettingControl.cpp in Sources */, + DFECFB8A172D9E4C00A43CF7 /* SettingDependency.cpp in Sources */, + DFECFB8B172D9E4C00A43CF7 /* SettingPath.cpp in Sources */, + DFECFB8C172D9E4C00A43CF7 /* SettingSection.cpp in Sources */, + DFECFB8D172D9E4C00A43CF7 /* SettingsManager.cpp in Sources */, + DFECFB8E172D9E4C00A43CF7 /* SettingUpdate.cpp in Sources */, + DFECFB8F172D9E4C00A43CF7 /* SettingVisibility.cpp in Sources */, + DFECFB92172D9E6D00A43CF7 /* BooleanLogic.cpp in Sources */, + DFECFBFD172DA58800A43CF7 /* NetworkServices.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/XBMC-IOS.xcodeproj/project.pbxproj b/XBMC-IOS.xcodeproj/project.pbxproj index 354e9a91bf8f2..8d524a6d5e2bb 100644 --- a/XBMC-IOS.xcodeproj/project.pbxproj +++ b/XBMC-IOS.xcodeproj/project.pbxproj @@ -264,6 +264,21 @@ DFDB00271516403A005079A4 /* MemBufferCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFDB00221516403A005079A4 /* MemBufferCache.cpp */; }; DFDD077316C0B58B000A1F73 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DFDD077216C0B58B000A1F73 /* Default-568h@2x.png */; }; DFE3505B1532535500F84CAA /* IOSKeyboardView.mm in Sources */ = {isa = PBXBuildFile; fileRef = DFE3505A1532535500F84CAA /* IOSKeyboardView.mm */; }; + DFECFAEB172D9C7B00A43CF7 /* GUIControlSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFAE9172D9C7B00A43CF7 /* GUIControlSettings.cpp */; }; + DFECFB39172D9D2800A43CF7 /* ISetting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB1F172D9D2800A43CF7 /* ISetting.cpp */; }; + DFECFB3A172D9D2800A43CF7 /* Setting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB23172D9D2800A43CF7 /* Setting.cpp */; }; + DFECFB3B172D9D2800A43CF7 /* SettingAddon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB25172D9D2800A43CF7 /* SettingAddon.cpp */; }; + DFECFB3C172D9D2800A43CF7 /* SettingCategoryAccess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB27172D9D2800A43CF7 /* SettingCategoryAccess.cpp */; }; + DFECFB3D172D9D2800A43CF7 /* SettingConditions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB29172D9D2800A43CF7 /* SettingConditions.cpp */; }; + DFECFB3E172D9D2800A43CF7 /* SettingControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB2B172D9D2800A43CF7 /* SettingControl.cpp */; }; + DFECFB3F172D9D2800A43CF7 /* SettingDependency.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB2D172D9D2800A43CF7 /* SettingDependency.cpp */; }; + DFECFB40172D9D2800A43CF7 /* SettingPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB2F172D9D2800A43CF7 /* SettingPath.cpp */; }; + DFECFB41172D9D2800A43CF7 /* SettingSection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB31172D9D2800A43CF7 /* SettingSection.cpp */; }; + DFECFB42172D9D2800A43CF7 /* SettingsManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB33172D9D2800A43CF7 /* SettingsManager.cpp */; }; + DFECFB43172D9D2800A43CF7 /* SettingUpdate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB35172D9D2800A43CF7 /* SettingUpdate.cpp */; }; + DFECFB44172D9D2800A43CF7 /* SettingVisibility.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB37172D9D2800A43CF7 /* SettingVisibility.cpp */; }; + DFECFB47172D9D4900A43CF7 /* BooleanLogic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB45172D9D4900A43CF7 /* BooleanLogic.cpp */; }; + DFECFB4F172D9D8E00A43CF7 /* NetworkServices.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB4D172D9D8E00A43CF7 /* NetworkServices.cpp */; }; DFF7A92315F7C62900D316E9 /* PltMimeType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFF7A91F15F7C62900D316E9 /* PltMimeType.cpp */; }; DFF7A92415F7C62900D316E9 /* PltProtocolInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFF7A92115F7C62900D316E9 /* PltProtocolInfo.cpp */; }; DFF7A93215F7C73B00D316E9 /* NptPosixTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFF7A93015F7C73B00D316E9 /* NptPosixTime.cpp */; }; @@ -276,7 +291,6 @@ F52CC6361713AD5100113454 /* DirectoryNodeGrouped.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F52CC6341713AD5100113454 /* DirectoryNodeGrouped.cpp */; }; F52CC6C71713BDEE00113454 /* DirectoryNodeGrouped.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F52CC6C51713BDEE00113454 /* DirectoryNodeGrouped.cpp */; }; F56352D916E543BD00D21BAD /* UPnPSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56352D716E543BD00D21BAD /* UPnPSettings.cpp */; }; - F56352E916E543F800D21BAD /* GUISettingControls.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56352DD16E543F800D21BAD /* GUISettingControls.cpp */; }; F56352EA16E543F800D21BAD /* GUIWindowSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56352DF16E543F800D21BAD /* GUIWindowSettings.cpp */; }; F56352EB16E543F800D21BAD /* GUIWindowSettingsCategory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56352E116E543F800D21BAD /* GUIWindowSettingsCategory.cpp */; }; F56352ED16E543F800D21BAD /* GUIWindowSettingsScreenCalibration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56352E516E543F800D21BAD /* GUIWindowSettingsScreenCalibration.cpp */; }; @@ -864,7 +878,6 @@ F56C8ADC131F42ED000AD0F6 /* GUIWindowPrograms.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C86A4131F42EB000AD0F6 /* GUIWindowPrograms.cpp */; }; F56C8ADF131F42ED000AD0F6 /* RenderSystemGLES.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C86AC131F42EB000AD0F6 /* RenderSystemGLES.cpp */; }; F56C8AE0131F42ED000AD0F6 /* RenderSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C86AE131F42EB000AD0F6 /* RenderSystem.cpp */; }; - F56C8AE6131F42ED000AD0F6 /* GUISettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C86BC131F42EB000AD0F6 /* GUISettings.cpp */; }; F56C8AE7131F42ED000AD0F6 /* AdvancedSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C86BE131F42EB000AD0F6 /* AdvancedSettings.cpp */; }; F56C8AED131F42ED000AD0F6 /* Settings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C86CA131F42EB000AD0F6 /* Settings.cpp */; }; F56C8AEF131F42ED000AD0F6 /* VideoSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C86CE131F42EB000AD0F6 /* VideoSettings.cpp */; }; @@ -1571,6 +1584,38 @@ DFDD077216C0B58B000A1F73 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; DFE350591532535500F84CAA /* IOSKeyboardView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IOSKeyboardView.h; sourceTree = ""; }; DFE3505A1532535500F84CAA /* IOSKeyboardView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IOSKeyboardView.mm; sourceTree = ""; }; + DFECFAE9172D9C7B00A43CF7 /* GUIControlSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GUIControlSettings.cpp; path = windows/GUIControlSettings.cpp; sourceTree = ""; }; + DFECFAEA172D9C7B00A43CF7 /* GUIControlSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GUIControlSettings.h; path = windows/GUIControlSettings.h; sourceTree = ""; }; + DFECFB1F172D9D2800A43CF7 /* ISetting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ISetting.cpp; sourceTree = ""; }; + DFECFB20172D9D2800A43CF7 /* ISetting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISetting.h; sourceTree = ""; }; + DFECFB21172D9D2800A43CF7 /* ISettingCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISettingCallback.h; sourceTree = ""; }; + DFECFB22172D9D2800A43CF7 /* ISettingCreator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISettingCreator.h; sourceTree = ""; }; + DFECFB23172D9D2800A43CF7 /* Setting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Setting.cpp; sourceTree = ""; }; + DFECFB24172D9D2800A43CF7 /* Setting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Setting.h; sourceTree = ""; }; + DFECFB25172D9D2800A43CF7 /* SettingAddon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingAddon.cpp; sourceTree = ""; }; + DFECFB26172D9D2800A43CF7 /* SettingAddon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingAddon.h; sourceTree = ""; }; + DFECFB27172D9D2800A43CF7 /* SettingCategoryAccess.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingCategoryAccess.cpp; sourceTree = ""; }; + DFECFB28172D9D2800A43CF7 /* SettingCategoryAccess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingCategoryAccess.h; sourceTree = ""; }; + DFECFB29172D9D2800A43CF7 /* SettingConditions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingConditions.cpp; sourceTree = ""; }; + DFECFB2A172D9D2800A43CF7 /* SettingConditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingConditions.h; sourceTree = ""; }; + DFECFB2B172D9D2800A43CF7 /* SettingControl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingControl.cpp; sourceTree = ""; }; + DFECFB2C172D9D2800A43CF7 /* SettingControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingControl.h; sourceTree = ""; }; + DFECFB2D172D9D2800A43CF7 /* SettingDependency.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingDependency.cpp; sourceTree = ""; }; + DFECFB2E172D9D2800A43CF7 /* SettingDependency.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingDependency.h; sourceTree = ""; }; + DFECFB2F172D9D2800A43CF7 /* SettingPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingPath.cpp; sourceTree = ""; }; + DFECFB30172D9D2800A43CF7 /* SettingPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingPath.h; sourceTree = ""; }; + DFECFB31172D9D2800A43CF7 /* SettingSection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingSection.cpp; sourceTree = ""; }; + DFECFB32172D9D2800A43CF7 /* SettingSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingSection.h; sourceTree = ""; }; + DFECFB33172D9D2800A43CF7 /* SettingsManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingsManager.cpp; sourceTree = ""; }; + DFECFB34172D9D2800A43CF7 /* SettingsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsManager.h; sourceTree = ""; }; + DFECFB35172D9D2800A43CF7 /* SettingUpdate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingUpdate.cpp; sourceTree = ""; }; + DFECFB36172D9D2800A43CF7 /* SettingUpdate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingUpdate.h; sourceTree = ""; }; + DFECFB37172D9D2800A43CF7 /* SettingVisibility.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingVisibility.cpp; sourceTree = ""; }; + DFECFB38172D9D2800A43CF7 /* SettingVisibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingVisibility.h; sourceTree = ""; }; + DFECFB45172D9D4900A43CF7 /* BooleanLogic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BooleanLogic.cpp; sourceTree = ""; }; + DFECFB46172D9D4900A43CF7 /* BooleanLogic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BooleanLogic.h; sourceTree = ""; }; + DFECFB4D172D9D8E00A43CF7 /* NetworkServices.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkServices.cpp; sourceTree = ""; }; + DFECFB4E172D9D8E00A43CF7 /* NetworkServices.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkServices.h; sourceTree = ""; }; DFF7A91F15F7C62900D316E9 /* PltMimeType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PltMimeType.cpp; sourceTree = ""; }; DFF7A92015F7C62900D316E9 /* PltMimeType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PltMimeType.h; sourceTree = ""; }; DFF7A92115F7C62900D316E9 /* PltProtocolInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PltProtocolInfo.cpp; sourceTree = ""; }; @@ -1604,8 +1649,6 @@ F558F61013AFDC3000631E12 /* ThreadLocal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadLocal.h; sourceTree = ""; }; F56352D716E543BD00D21BAD /* UPnPSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UPnPSettings.cpp; sourceTree = ""; }; F56352D816E543BD00D21BAD /* UPnPSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UPnPSettings.h; sourceTree = ""; }; - F56352DD16E543F800D21BAD /* GUISettingControls.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GUISettingControls.cpp; path = windows/GUISettingControls.cpp; sourceTree = ""; }; - F56352DE16E543F800D21BAD /* GUISettingControls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GUISettingControls.h; path = windows/GUISettingControls.h; sourceTree = ""; }; F56352DF16E543F800D21BAD /* GUIWindowSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GUIWindowSettings.cpp; path = windows/GUIWindowSettings.cpp; sourceTree = ""; }; F56352E016E543F800D21BAD /* GUIWindowSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GUIWindowSettings.h; path = windows/GUIWindowSettings.h; sourceTree = ""; }; F56352E116E543F800D21BAD /* GUIWindowSettingsCategory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GUIWindowSettingsCategory.cpp; path = windows/GUIWindowSettingsCategory.cpp; sourceTree = ""; }; @@ -2909,8 +2952,6 @@ F56C86AD131F42EB000AD0F6 /* RenderSystemGLES.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSystemGLES.h; sourceTree = ""; }; F56C86AE131F42EB000AD0F6 /* RenderSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSystem.cpp; sourceTree = ""; }; F56C86AF131F42EB000AD0F6 /* RenderSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSystem.h; sourceTree = ""; }; - F56C86BC131F42EB000AD0F6 /* GUISettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GUISettings.cpp; sourceTree = ""; }; - F56C86BD131F42EB000AD0F6 /* GUISettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUISettings.h; sourceTree = ""; }; F56C86BE131F42EB000AD0F6 /* AdvancedSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AdvancedSettings.cpp; sourceTree = ""; }; F56C86BF131F42EB000AD0F6 /* AdvancedSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdvancedSettings.h; sourceTree = ""; }; F56C86CA131F42EB000AD0F6 /* Settings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Settings.cpp; sourceTree = ""; }; @@ -3828,8 +3869,8 @@ F56352DB16E543DE00D21BAD /* windows */ = { isa = PBXGroup; children = ( - F56352DD16E543F800D21BAD /* GUISettingControls.cpp */, - F56352DE16E543F800D21BAD /* GUISettingControls.h */, + DFECFAE9172D9C7B00A43CF7 /* GUIControlSettings.cpp */, + DFECFAEA172D9C7B00A43CF7 /* GUIControlSettings.h */, F56352DF16E543F800D21BAD /* GUIWindowSettings.cpp */, F56352E016E543F800D21BAD /* GUIWindowSettings.h */, F56352E116E543F800D21BAD /* GUIWindowSettingsCategory.cpp */, @@ -5896,6 +5937,8 @@ F56C8645131F42EB000AD0F6 /* GUIDialogNetworkSetup.h */, F56C8646131F42EB000AD0F6 /* Network.cpp */, F56C8647131F42EB000AD0F6 /* Network.h */, + DFECFB4D172D9D8E00A43CF7 /* NetworkServices.cpp */, + DFECFB4E172D9D8E00A43CF7 /* NetworkServices.h */, F56C8648131F42EB000AD0F6 /* Socket.cpp */, F56C8649131F42EB000AD0F6 /* Socket.h */, F56C864A131F42EB000AD0F6 /* TCPServer.cpp */, @@ -6072,16 +6115,40 @@ F56C86BF131F42EB000AD0F6 /* AdvancedSettings.h */, DF28EE0A170E1E78005FA9D2 /* DisplaySettings.cpp */, DF28EE0B170E1E78005FA9D2 /* DisplaySettings.h */, - F56C86BC131F42EB000AD0F6 /* GUISettings.cpp */, - F56C86BD131F42EB000AD0F6 /* GUISettings.h */, + DFECFB1F172D9D2800A43CF7 /* ISetting.cpp */, + DFECFB20172D9D2800A43CF7 /* ISetting.h */, + DFECFB21172D9D2800A43CF7 /* ISettingCallback.h */, + DFECFB22172D9D2800A43CF7 /* ISettingCreator.h */, DF898FBA1709B8E600B35C21 /* ISettingsHandler.h */, DF898FBB1709B8E600B35C21 /* ISubSettings.h */, DF898FBC1709B8E600B35C21 /* MediaSettings.cpp */, DF898FBD1709B8E600B35C21 /* MediaSettings.h */, DF898FBE1709B8E600B35C21 /* MediaSourceSettings.cpp */, DF898FBF1709B8E600B35C21 /* MediaSourceSettings.h */, + DFECFB23172D9D2800A43CF7 /* Setting.cpp */, + DFECFB24172D9D2800A43CF7 /* Setting.h */, + DFECFB25172D9D2800A43CF7 /* SettingAddon.cpp */, + DFECFB26172D9D2800A43CF7 /* SettingAddon.h */, + DFECFB27172D9D2800A43CF7 /* SettingCategoryAccess.cpp */, + DFECFB28172D9D2800A43CF7 /* SettingCategoryAccess.h */, + DFECFB29172D9D2800A43CF7 /* SettingConditions.cpp */, + DFECFB2A172D9D2800A43CF7 /* SettingConditions.h */, + DFECFB2B172D9D2800A43CF7 /* SettingControl.cpp */, + DFECFB2C172D9D2800A43CF7 /* SettingControl.h */, + DFECFB2D172D9D2800A43CF7 /* SettingDependency.cpp */, + DFECFB2E172D9D2800A43CF7 /* SettingDependency.h */, + DFECFB2F172D9D2800A43CF7 /* SettingPath.cpp */, + DFECFB30172D9D2800A43CF7 /* SettingPath.h */, F56C86CA131F42EB000AD0F6 /* Settings.cpp */, F56C86CB131F42EB000AD0F6 /* Settings.h */, + DFECFB31172D9D2800A43CF7 /* SettingSection.cpp */, + DFECFB32172D9D2800A43CF7 /* SettingSection.h */, + DFECFB33172D9D2800A43CF7 /* SettingsManager.cpp */, + DFECFB34172D9D2800A43CF7 /* SettingsManager.h */, + DFECFB35172D9D2800A43CF7 /* SettingUpdate.cpp */, + DFECFB36172D9D2800A43CF7 /* SettingUpdate.h */, + DFECFB37172D9D2800A43CF7 /* SettingVisibility.cpp */, + DFECFB38172D9D2800A43CF7 /* SettingVisibility.h */, DF898FC01709B8E600B35C21 /* SkinSettings.cpp */, DF898FC11709B8E600B35C21 /* SkinSettings.h */, F56C86CE131F42EB000AD0F6 /* VideoSettings.cpp */, @@ -6160,6 +6227,8 @@ DF52775D151BAFA000B5B63B /* Base64.h */, F56C8716131F42EC000AD0F6 /* BitstreamStats.cpp */, F56C8717131F42EC000AD0F6 /* BitstreamStats.h */, + DFECFB45172D9D4900A43CF7 /* BooleanLogic.cpp */, + DFECFB46172D9D4900A43CF7 /* BooleanLogic.h */, F56C8718131F42EC000AD0F6 /* CharsetConverter.cpp */, F56C8719131F42EC000AD0F6 /* CharsetConverter.h */, F56C871A131F42EC000AD0F6 /* CPUInfo.cpp */, @@ -7331,7 +7400,6 @@ F56C8ADC131F42ED000AD0F6 /* GUIWindowPrograms.cpp in Sources */, F56C8ADF131F42ED000AD0F6 /* RenderSystemGLES.cpp in Sources */, F56C8AE0131F42ED000AD0F6 /* RenderSystem.cpp in Sources */, - F56C8AE6131F42ED000AD0F6 /* GUISettings.cpp in Sources */, F56C8AE7131F42ED000AD0F6 /* AdvancedSettings.cpp in Sources */, F56C8AED131F42ED000AD0F6 /* Settings.cpp in Sources */, F56C8AEF131F42ED000AD0F6 /* VideoSettings.cpp in Sources */, @@ -7731,7 +7799,6 @@ DFD5813116C829350008EEA0 /* DAVCommon.cpp in Sources */, DFD5813216C829350008EEA0 /* DAVFile.cpp in Sources */, F56352D916E543BD00D21BAD /* UPnPSettings.cpp in Sources */, - F56352E916E543F800D21BAD /* GUISettingControls.cpp in Sources */, F56352EA16E543F800D21BAD /* GUIWindowSettings.cpp in Sources */, F56352EB16E543F800D21BAD /* GUIWindowSettingsCategory.cpp in Sources */, F56352ED16E543F800D21BAD /* GUIWindowSettingsScreenCalibration.cpp in Sources */, @@ -7756,6 +7823,21 @@ 7C87B2DA162CE3C300EF897D /* PlayerController.cpp in Sources */, F52CC6361713AD5100113454 /* DirectoryNodeGrouped.cpp in Sources */, F52CC6C71713BDEE00113454 /* DirectoryNodeGrouped.cpp in Sources */, + DFECFAEB172D9C7B00A43CF7 /* GUIControlSettings.cpp in Sources */, + DFECFB39172D9D2800A43CF7 /* ISetting.cpp in Sources */, + DFECFB3A172D9D2800A43CF7 /* Setting.cpp in Sources */, + DFECFB3B172D9D2800A43CF7 /* SettingAddon.cpp in Sources */, + DFECFB3C172D9D2800A43CF7 /* SettingCategoryAccess.cpp in Sources */, + DFECFB3D172D9D2800A43CF7 /* SettingConditions.cpp in Sources */, + DFECFB3E172D9D2800A43CF7 /* SettingControl.cpp in Sources */, + DFECFB3F172D9D2800A43CF7 /* SettingDependency.cpp in Sources */, + DFECFB40172D9D2800A43CF7 /* SettingPath.cpp in Sources */, + DFECFB41172D9D2800A43CF7 /* SettingSection.cpp in Sources */, + DFECFB42172D9D2800A43CF7 /* SettingsManager.cpp in Sources */, + DFECFB43172D9D2800A43CF7 /* SettingUpdate.cpp in Sources */, + DFECFB44172D9D2800A43CF7 /* SettingVisibility.cpp in Sources */, + DFECFB47172D9D4900A43CF7 /* BooleanLogic.cpp in Sources */, + DFECFB4F172D9D8E00A43CF7 /* NetworkServices.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/XBMC.xcodeproj/project.pbxproj b/XBMC.xcodeproj/project.pbxproj index 7d41f3f165892..ab12ecfda0ee0 100644 --- a/XBMC.xcodeproj/project.pbxproj +++ b/XBMC.xcodeproj/project.pbxproj @@ -137,7 +137,6 @@ 18B7C8A0129423A7009E7A26 /* MusicInfoTagLoaderSPC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 18B7C87E129423A7009E7A26 /* MusicInfoTagLoaderSPC.cpp */; }; 18B7C8A1129423A7009E7A26 /* MusicInfoTagLoaderWav.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 18B7C880129423A7009E7A26 /* MusicInfoTagLoaderWav.cpp */; }; 18B7C8A4129423A7009E7A26 /* MusicInfoTagLoaderYM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 18B7C886129423A7009E7A26 /* MusicInfoTagLoaderYM.cpp */; }; - 18B7C8C412942451009E7A26 /* GUISettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 18B7C8C212942451009E7A26 /* GUISettings.cpp */; }; 18B7C8D712942546009E7A26 /* ButtonTranslator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 18B7C8CB12942546009E7A26 /* ButtonTranslator.cpp */; }; 18B7C8D812942546009E7A26 /* KeyboardLayoutConfiguration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 18B7C8CD12942546009E7A26 /* KeyboardLayoutConfiguration.cpp */; }; 18B7C8D912942546009E7A26 /* KeyboardStat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 18B7C8CF12942546009E7A26 /* KeyboardStat.cpp */; }; @@ -502,6 +501,21 @@ DFD5812616C828500008EEA0 /* DAVFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFD5812316C828500008EEA0 /* DAVFile.cpp */; }; DFD928F316384B6800709DAE /* Timer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFD928F116384B6800709DAE /* Timer.cpp */; }; DFDA3153160E34230047A626 /* DVDOverlayCodec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFDA3152160E34230047A626 /* DVDOverlayCodec.cpp */; }; + DFECFADF172D9C5100A43CF7 /* GUIControlSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFADD172D9C5100A43CF7 /* GUIControlSettings.cpp */; }; + DFECFB07172D9CAB00A43CF7 /* ISetting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFAEE172D9CAB00A43CF7 /* ISetting.cpp */; }; + DFECFB08172D9CAB00A43CF7 /* Setting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFAF2172D9CAB00A43CF7 /* Setting.cpp */; }; + DFECFB09172D9CAB00A43CF7 /* SettingAddon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFAF4172D9CAB00A43CF7 /* SettingAddon.cpp */; }; + DFECFB0A172D9CAB00A43CF7 /* SettingCategoryAccess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFAF6172D9CAB00A43CF7 /* SettingCategoryAccess.cpp */; }; + DFECFB0B172D9CAB00A43CF7 /* SettingConditions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFAF8172D9CAB00A43CF7 /* SettingConditions.cpp */; }; + DFECFB0C172D9CAB00A43CF7 /* SettingControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFAFA172D9CAB00A43CF7 /* SettingControl.cpp */; }; + DFECFB0D172D9CAB00A43CF7 /* SettingDependency.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFAFC172D9CAB00A43CF7 /* SettingDependency.cpp */; }; + DFECFB0E172D9CAB00A43CF7 /* SettingPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFAFE172D9CAB00A43CF7 /* SettingPath.cpp */; }; + DFECFB0F172D9CAB00A43CF7 /* SettingSection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB00172D9CAB00A43CF7 /* SettingSection.cpp */; }; + DFECFB10172D9CAB00A43CF7 /* SettingsManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB02172D9CAB00A43CF7 /* SettingsManager.cpp */; }; + DFECFB11172D9CAB00A43CF7 /* SettingUpdate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB03172D9CAB00A43CF7 /* SettingUpdate.cpp */; }; + DFECFB12172D9CAB00A43CF7 /* SettingVisibility.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB05172D9CAB00A43CF7 /* SettingVisibility.cpp */; }; + DFECFB1C172D9D0100A43CF7 /* BooleanLogic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB1A172D9D0100A43CF7 /* BooleanLogic.cpp */; }; + DFECFB4C172D9D6D00A43CF7 /* NetworkServices.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DFECFB4A172D9D6D00A43CF7 /* NetworkServices.cpp */; }; E306D12E0DDF7B590052C2AD /* XBMCHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E306D12C0DDF7B590052C2AD /* XBMCHelper.cpp */; }; E33206380D5070AA00435CE3 /* DVDDemuxVobsub.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E33206370D5070AA00435CE3 /* DVDDemuxVobsub.cpp */; }; E33466A60D2E5103005A65EC /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E33466A50D2E5103005A65EC /* IOKit.framework */; }; @@ -948,7 +962,6 @@ F563529616E53FAB00D21BAD /* UPnPSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F563529416E53FAB00D21BAD /* UPnPSettings.cpp */; settings = {COMPILER_FLAGS = "-I$SRCROOT/lib/libUPnP/Platinum/Source/Core -I$SRCROOT/lib/libUPnP/Platinum/Source/Platinum -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaConnect -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaRenderer -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaServer -I$SRCROOT/lib/libUPnP/Platinum/Source/Extras -I$SRCROOT/lib/libUPnP/Neptune/Source/System/Posix -I$SRCROOT/lib/libUPnP/Neptune/Source/Core"; }; }; F56352AA16E5402100D21BAD /* GUIDialogContentSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56352A216E5402100D21BAD /* GUIDialogContentSettings.cpp */; }; F56352AD16E5402100D21BAD /* GUIDialogSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56352A816E5402100D21BAD /* GUIDialogSettings.cpp */; }; - F56352BA16E5403400D21BAD /* GUISettingControls.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56352AE16E5403400D21BAD /* GUISettingControls.cpp */; }; F56352BB16E5403400D21BAD /* GUIWindowSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56352B016E5403400D21BAD /* GUIWindowSettings.cpp */; }; F56352BC16E5403400D21BAD /* GUIWindowSettingsCategory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56352B216E5403400D21BAD /* GUIWindowSettingsCategory.cpp */; }; F56352BE16E5403400D21BAD /* GUIWindowSettingsScreenCalibration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56352B616E5403400D21BAD /* GUIWindowSettingsScreenCalibration.cpp */; }; @@ -1302,8 +1315,6 @@ 18B7C881129423A7009E7A26 /* MusicInfoTagLoaderWav.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MusicInfoTagLoaderWav.h; sourceTree = ""; }; 18B7C886129423A7009E7A26 /* MusicInfoTagLoaderYM.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MusicInfoTagLoaderYM.cpp; sourceTree = ""; }; 18B7C887129423A7009E7A26 /* MusicInfoTagLoaderYM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MusicInfoTagLoaderYM.h; sourceTree = ""; }; - 18B7C8C212942451009E7A26 /* GUISettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GUISettings.cpp; sourceTree = ""; }; - 18B7C8C312942451009E7A26 /* GUISettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUISettings.h; sourceTree = ""; }; 18B7C8CB12942546009E7A26 /* ButtonTranslator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ButtonTranslator.cpp; sourceTree = ""; }; 18B7C8CC12942546009E7A26 /* ButtonTranslator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ButtonTranslator.h; sourceTree = ""; }; 18B7C8CD12942546009E7A26 /* KeyboardLayoutConfiguration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeyboardLayoutConfiguration.cpp; sourceTree = ""; }; @@ -2083,6 +2094,37 @@ DFD928F116384B6800709DAE /* Timer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Timer.cpp; sourceTree = ""; }; DFD928F216384B6800709DAE /* Timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Timer.h; sourceTree = ""; }; DFDA3152160E34230047A626 /* DVDOverlayCodec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DVDOverlayCodec.cpp; sourceTree = ""; }; + DFECFADD172D9C5100A43CF7 /* GUIControlSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GUIControlSettings.cpp; path = windows/GUIControlSettings.cpp; sourceTree = ""; }; + DFECFADE172D9C5100A43CF7 /* GUIControlSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GUIControlSettings.h; path = windows/GUIControlSettings.h; sourceTree = ""; }; + DFECFAEE172D9CAB00A43CF7 /* ISetting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ISetting.cpp; sourceTree = ""; }; + DFECFAEF172D9CAB00A43CF7 /* ISetting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISetting.h; sourceTree = ""; }; + DFECFAF0172D9CAB00A43CF7 /* ISettingCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISettingCallback.h; sourceTree = ""; }; + DFECFAF1172D9CAB00A43CF7 /* ISettingCreator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISettingCreator.h; sourceTree = ""; }; + DFECFAF2172D9CAB00A43CF7 /* Setting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Setting.cpp; sourceTree = ""; }; + DFECFAF3172D9CAB00A43CF7 /* Setting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Setting.h; sourceTree = ""; }; + DFECFAF4172D9CAB00A43CF7 /* SettingAddon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingAddon.cpp; sourceTree = ""; }; + DFECFAF5172D9CAB00A43CF7 /* SettingAddon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingAddon.h; sourceTree = ""; }; + DFECFAF6172D9CAB00A43CF7 /* SettingCategoryAccess.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingCategoryAccess.cpp; sourceTree = ""; }; + DFECFAF7172D9CAB00A43CF7 /* SettingCategoryAccess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingCategoryAccess.h; sourceTree = ""; }; + DFECFAF8172D9CAB00A43CF7 /* SettingConditions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingConditions.cpp; sourceTree = ""; }; + DFECFAF9172D9CAB00A43CF7 /* SettingConditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingConditions.h; sourceTree = ""; }; + DFECFAFA172D9CAB00A43CF7 /* SettingControl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingControl.cpp; sourceTree = ""; }; + DFECFAFB172D9CAB00A43CF7 /* SettingControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingControl.h; sourceTree = ""; }; + DFECFAFC172D9CAB00A43CF7 /* SettingDependency.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingDependency.cpp; sourceTree = ""; }; + DFECFAFD172D9CAB00A43CF7 /* SettingDependency.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingDependency.h; sourceTree = ""; }; + DFECFAFE172D9CAB00A43CF7 /* SettingPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingPath.cpp; sourceTree = ""; }; + DFECFAFF172D9CAB00A43CF7 /* SettingPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingPath.h; sourceTree = ""; }; + DFECFB00172D9CAB00A43CF7 /* SettingSection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingSection.cpp; sourceTree = ""; }; + DFECFB01172D9CAB00A43CF7 /* SettingSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingSection.h; sourceTree = ""; }; + DFECFB02172D9CAB00A43CF7 /* SettingsManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingsManager.cpp; sourceTree = ""; }; + DFECFB03172D9CAB00A43CF7 /* SettingUpdate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingUpdate.cpp; sourceTree = ""; }; + DFECFB04172D9CAB00A43CF7 /* SettingUpdate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingUpdate.h; sourceTree = ""; }; + DFECFB05172D9CAB00A43CF7 /* SettingVisibility.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingVisibility.cpp; sourceTree = ""; }; + DFECFB06172D9CAB00A43CF7 /* SettingVisibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingVisibility.h; sourceTree = ""; }; + DFECFB1A172D9D0100A43CF7 /* BooleanLogic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BooleanLogic.cpp; sourceTree = ""; }; + DFECFB1B172D9D0100A43CF7 /* BooleanLogic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BooleanLogic.h; sourceTree = ""; }; + DFECFB4A172D9D6D00A43CF7 /* NetworkServices.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkServices.cpp; sourceTree = ""; }; + DFECFB4B172D9D6D00A43CF7 /* NetworkServices.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkServices.h; sourceTree = ""; }; E306D12C0DDF7B590052C2AD /* XBMCHelper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XBMCHelper.cpp; sourceTree = ""; }; E306D12D0DDF7B590052C2AD /* XBMCHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XBMCHelper.h; sourceTree = ""; }; E33206370D5070AA00435CE3 /* DVDDemuxVobsub.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DVDDemuxVobsub.cpp; sourceTree = ""; }; @@ -3080,8 +3122,6 @@ F56352A316E5402100D21BAD /* GUIDialogContentSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GUIDialogContentSettings.h; path = dialogs/GUIDialogContentSettings.h; sourceTree = ""; }; F56352A816E5402100D21BAD /* GUIDialogSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GUIDialogSettings.cpp; path = dialogs/GUIDialogSettings.cpp; sourceTree = ""; }; F56352A916E5402100D21BAD /* GUIDialogSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GUIDialogSettings.h; path = dialogs/GUIDialogSettings.h; sourceTree = ""; }; - F56352AE16E5403400D21BAD /* GUISettingControls.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GUISettingControls.cpp; path = windows/GUISettingControls.cpp; sourceTree = ""; }; - F56352AF16E5403400D21BAD /* GUISettingControls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GUISettingControls.h; path = windows/GUISettingControls.h; sourceTree = ""; }; F56352B016E5403400D21BAD /* GUIWindowSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GUIWindowSettings.cpp; path = windows/GUIWindowSettings.cpp; sourceTree = ""; }; F56352B116E5403400D21BAD /* GUIWindowSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GUIWindowSettings.h; path = windows/GUIWindowSettings.h; sourceTree = ""; }; F56352B216E5403400D21BAD /* GUIWindowSettingsCategory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GUIWindowSettingsCategory.cpp; path = windows/GUIWindowSettingsCategory.cpp; sourceTree = ""; }; @@ -3984,6 +4024,8 @@ E38E17C10D25F9FA00618676 /* GUIDialogNetworkSetup.h */, E38E1E6B0D25F9FD00618676 /* Network.cpp */, E38E1E6C0D25F9FD00618676 /* Network.h */, + DFECFB4A172D9D6D00A43CF7 /* NetworkServices.cpp */, + DFECFB4B172D9D6D00A43CF7 /* NetworkServices.h */, E3E91FFC0D8C61DF002BF43D /* Socket.cpp */, 6E97BDC40DA2B620003A2A89 /* Socket.h */, 432D7CF612D870E800CE4C49 /* TCPServer.cpp */, @@ -6103,16 +6145,39 @@ 18B7C3A712942132009E7A26 /* AdvancedSettings.h */, DF28EE01170E1E51005FA9D2 /* DisplaySettings.cpp */, DF28EE02170E1E51005FA9D2 /* DisplaySettings.h */, - 18B7C8C212942451009E7A26 /* GUISettings.cpp */, - 18B7C8C312942451009E7A26 /* GUISettings.h */, + DFECFAEE172D9CAB00A43CF7 /* ISetting.cpp */, + DFECFAEF172D9CAB00A43CF7 /* ISetting.h */, + DFECFAF0172D9CAB00A43CF7 /* ISettingCallback.h */, + DFECFAF1172D9CAB00A43CF7 /* ISettingCreator.h */, DF8990141709BB2D00B35C21 /* ISettingsHandler.h */, DF8990151709BB2D00B35C21 /* ISubSettings.h */, DF8990161709BB2D00B35C21 /* MediaSettings.cpp */, DF8990171709BB2D00B35C21 /* MediaSettings.h */, DF8990181709BB2D00B35C21 /* MediaSourceSettings.cpp */, DF8990191709BB2D00B35C21 /* MediaSourceSettings.h */, + DFECFAF2172D9CAB00A43CF7 /* Setting.cpp */, + DFECFAF3172D9CAB00A43CF7 /* Setting.h */, + DFECFAF4172D9CAB00A43CF7 /* SettingAddon.cpp */, + DFECFAF5172D9CAB00A43CF7 /* SettingAddon.h */, + DFECFAF6172D9CAB00A43CF7 /* SettingCategoryAccess.cpp */, + DFECFAF7172D9CAB00A43CF7 /* SettingCategoryAccess.h */, + DFECFAF8172D9CAB00A43CF7 /* SettingConditions.cpp */, + DFECFAF9172D9CAB00A43CF7 /* SettingConditions.h */, + DFECFAFA172D9CAB00A43CF7 /* SettingControl.cpp */, + DFECFAFB172D9CAB00A43CF7 /* SettingControl.h */, + DFECFAFC172D9CAB00A43CF7 /* SettingDependency.cpp */, + DFECFAFD172D9CAB00A43CF7 /* SettingDependency.h */, + DFECFAFE172D9CAB00A43CF7 /* SettingPath.cpp */, + DFECFAFF172D9CAB00A43CF7 /* SettingPath.h */, 18B7C38E129420E5009E7A26 /* Settings.cpp */, 18B7C38F129420E5009E7A26 /* Settings.h */, + DFECFB00172D9CAB00A43CF7 /* SettingSection.cpp */, + DFECFB01172D9CAB00A43CF7 /* SettingSection.h */, + DFECFB02172D9CAB00A43CF7 /* SettingsManager.cpp */, + DFECFB03172D9CAB00A43CF7 /* SettingUpdate.cpp */, + DFECFB04172D9CAB00A43CF7 /* SettingUpdate.h */, + DFECFB05172D9CAB00A43CF7 /* SettingVisibility.cpp */, + DFECFB06172D9CAB00A43CF7 /* SettingVisibility.h */, DF89901A1709BB2D00B35C21 /* SkinSettings.cpp */, DF89901B1709BB2D00B35C21 /* SkinSettings.h */, E38E1E010D25F9FD00618676 /* VideoSettings.cpp */, @@ -6140,6 +6205,8 @@ F56353BE16E9BB3500D21BAD /* BitstreamConverter.h */, E38E1E270D25F9FD00618676 /* BitstreamStats.cpp */, E38E1E280D25F9FD00618676 /* BitstreamStats.h */, + DFECFB1A172D9D0100A43CF7 /* BooleanLogic.cpp */, + DFECFB1B172D9D0100A43CF7 /* BooleanLogic.h */, E38E1E290D25F9FD00618676 /* CharsetConverter.cpp */, E38E1E2A0D25F9FD00618676 /* CharsetConverter.h */, E38E1E2B0D25F9FD00618676 /* CPUInfo.cpp */, @@ -6310,6 +6377,8 @@ F563529F16E53FE900D21BAD /* dialogs */ = { isa = PBXGroup; children = ( + DFECFADD172D9C5100A43CF7 /* GUIControlSettings.cpp */, + DFECFADE172D9C5100A43CF7 /* GUIControlSettings.h */, F56352A216E5402100D21BAD /* GUIDialogContentSettings.cpp */, F56352A316E5402100D21BAD /* GUIDialogContentSettings.h */, F56352A816E5402100D21BAD /* GUIDialogSettings.cpp */, @@ -6321,8 +6390,6 @@ F56352A016E53FF300D21BAD /* windows */ = { isa = PBXGroup; children = ( - F56352AE16E5403400D21BAD /* GUISettingControls.cpp */, - F56352AF16E5403400D21BAD /* GUISettingControls.h */, F56352B016E5403400D21BAD /* GUIWindowSettings.cpp */, F56352B116E5403400D21BAD /* GUIWindowSettings.h */, F56352B216E5403400D21BAD /* GUIWindowSettingsCategory.cpp */, @@ -7424,7 +7491,6 @@ 18B7C8A0129423A7009E7A26 /* MusicInfoTagLoaderSPC.cpp in Sources */, 18B7C8A1129423A7009E7A26 /* MusicInfoTagLoaderWav.cpp in Sources */, 18B7C8A4129423A7009E7A26 /* MusicInfoTagLoaderYM.cpp in Sources */, - 18B7C8C412942451009E7A26 /* GUISettings.cpp in Sources */, 18B7C8D712942546009E7A26 /* ButtonTranslator.cpp in Sources */, 18B7C8D812942546009E7A26 /* KeyboardLayoutConfiguration.cpp in Sources */, 18B7C8D912942546009E7A26 /* KeyboardStat.cpp in Sources */, @@ -7735,7 +7801,6 @@ F563529616E53FAB00D21BAD /* UPnPSettings.cpp in Sources */, F56352AA16E5402100D21BAD /* GUIDialogContentSettings.cpp in Sources */, F56352AD16E5402100D21BAD /* GUIDialogSettings.cpp in Sources */, - F56352BA16E5403400D21BAD /* GUISettingControls.cpp in Sources */, F56352BB16E5403400D21BAD /* GUIWindowSettings.cpp in Sources */, F56352BC16E5403400D21BAD /* GUIWindowSettingsCategory.cpp in Sources */, F56352BE16E5403400D21BAD /* GUIWindowSettingsScreenCalibration.cpp in Sources */, @@ -7756,6 +7821,21 @@ 7C87B2CE162CE39600EF897D /* PlayerController.cpp in Sources */, F52CC5F01713AAA200113454 /* DirectoryNodeGrouped.cpp in Sources */, F52CC6AA1713BD2B00113454 /* DirectoryNodeGrouped.cpp in Sources */, + DFECFADF172D9C5100A43CF7 /* GUIControlSettings.cpp in Sources */, + DFECFB07172D9CAB00A43CF7 /* ISetting.cpp in Sources */, + DFECFB08172D9CAB00A43CF7 /* Setting.cpp in Sources */, + DFECFB09172D9CAB00A43CF7 /* SettingAddon.cpp in Sources */, + DFECFB0A172D9CAB00A43CF7 /* SettingCategoryAccess.cpp in Sources */, + DFECFB0B172D9CAB00A43CF7 /* SettingConditions.cpp in Sources */, + DFECFB0C172D9CAB00A43CF7 /* SettingControl.cpp in Sources */, + DFECFB0D172D9CAB00A43CF7 /* SettingDependency.cpp in Sources */, + DFECFB0E172D9CAB00A43CF7 /* SettingPath.cpp in Sources */, + DFECFB0F172D9CAB00A43CF7 /* SettingSection.cpp in Sources */, + DFECFB10172D9CAB00A43CF7 /* SettingsManager.cpp in Sources */, + DFECFB11172D9CAB00A43CF7 /* SettingUpdate.cpp in Sources */, + DFECFB12172D9CAB00A43CF7 /* SettingVisibility.cpp in Sources */, + DFECFB1C172D9D0100A43CF7 /* BooleanLogic.cpp in Sources */, + DFECFB4C172D9D6D00A43CF7 /* NetworkServices.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/addons/skin.confluence/720p/SettingsCategory.xml b/addons/skin.confluence/720p/SettingsCategory.xml index fda12b369514c..ace6202b6127d 100644 --- a/addons/skin.confluence/720p/SettingsCategory.xml +++ b/addons/skin.confluence/720p/SettingsCategory.xml @@ -70,7 +70,7 @@ 260 481 -1 - 60 + 9000 5 3 3 @@ -225,6 +225,44 @@ + + -250 + SideBladeLeft + + 0 + 110 + 250 + 600 + 9000 + 3 + 9000 + 9000 + 3 + 0 + + 250 + 35 + font12 + + blue + center + center + + + Setting level button + 235 + ButtonCommonValues + + SettingsLevelChange + + + Reset button + ButtonCommonValues + + SettingsReset + + + Clock diff --git a/addons/skin.confluence/language/English/strings.po b/addons/skin.confluence/language/English/strings.po index d6024513d2742..445e44a94e04a 100644 --- a/addons/skin.confluence/language/English/strings.po +++ b/addons/skin.confluence/language/English/strings.po @@ -41,7 +41,9 @@ msgctxt "#31006" msgid "View Options" msgstr "" -#empty string with id 31007 +msgctxt "#31007" +msgid "Settings Options" +msgstr "" msgctxt "#31008" msgid "Fullscreen" diff --git a/language/English/strings.po b/language/English/strings.po index dfc125cf4c79a..6c96360b1488b 100644 --- a/language/English/strings.po +++ b/language/English/strings.po @@ -3617,7 +3617,9 @@ msgctxt "#1273" msgid "AirPlay" msgstr "" -#empty string with id 1274 +msgctxt "#1274" +msgid "AirTunes" +msgstr "" #. Filter movies/tvshows/music/episodes/artists/musicvideos/albums/songs #: xbmc/dialogs/GUIDialogMediaFilter.cpp @@ -4080,14 +4082,48 @@ msgctxt "#10034" msgid "Settings - Profiles" msgstr "" -#empty strings from id 10035 to 10039 +msgctxt "#10035" +msgid "Reset" +msgstr "" + +msgctxt "#10036" +msgid "Level: Basic" +msgstr "" + +msgctxt "#10037" +msgid "Level: Standard" +msgstr "" + +msgctxt "#10038" +msgid "Level: Advanced" +msgstr "" + +msgctxt "#10039" +msgid "Level: Expert" +msgstr "" #: xbmc/guilib/WindowIDs.h msgctxt "#10040" msgid "Addon browser" msgstr "" -#empty strings from id 10041 to 10099 +msgctxt "#10041" +msgid "Reset settings" +msgstr "" + +msgctxt "#10042" +msgid "Are you sure you want to reset the settings in this category?" +msgstr "" + +msgctxt "#10043" +msgid "Help" +msgstr "" + +msgctxt "#10044" +msgid "No help available" +msgstr "" + +#empty strings from id 10045 to 10099 #: xbmc/guilib/WindowIDs.h msgctxt "#10100" @@ -5669,7 +5705,7 @@ msgstr "" #: xbmc/settings/GUISettings.cpp msgctxt "#13435" -msgid "Enable HQ Scalers for scalings above %" +msgid "Enable HQ Scalers for scalings above" msgstr "" #empty strings from id 13436 to 13499 @@ -12060,7 +12096,7 @@ msgstr "" xbmc\network\windows\ZeroconfWIN.cpp msgctxt "#34300" -msgid "Failed to start zeroconf" +msgid "Failed to start Zeroconf" msgstr "" #: xbmc\network\windows\ZeroconfWIN.cpp @@ -12068,7 +12104,19 @@ msgctxt "#34301" msgid "Is Apple's Bonjour Service installed? See log for more info." msgstr "" -#empty strings from id 34302 to 34399 +msgctxt "#34302" +msgid "AirPlay requires Zeroconf to be enabled." +msgstr "" + +msgctxt "#34303" +msgid "Unable to stop Zeroconf" +msgstr "" + +msgctxt "#34304" +msgid "AirPlay and AirTunes depend on Zeroconf running." +msgstr "" + +#empty strings from id 34305 to 34399 #: xbmc\cores\VideoRenderers\LinuxRendererGL.cpp msgctxt "#34400" diff --git a/project/VS2010Express/XBMC.vcxproj b/project/VS2010Express/XBMC.vcxproj index 3afa612cc1a40..e74b510cc02cb 100644 --- a/project/VS2010Express/XBMC.vcxproj +++ b/project/VS2010Express/XBMC.vcxproj @@ -836,6 +836,7 @@ + @@ -952,13 +953,24 @@ - + + + + + + + + + + + + - + @@ -1103,6 +1115,7 @@ + @@ -1113,17 +1126,33 @@ + + + + + + + + + + + + + + - + + + @@ -1261,6 +1290,7 @@ + true @@ -2356,7 +2386,6 @@ - @@ -2945,4 +2974,4 @@ - + \ No newline at end of file diff --git a/project/VS2010Express/XBMC.vcxproj.filters b/project/VS2010Express/XBMC.vcxproj.filters index 4be787ca6712c..51d27fbd71b62 100644 --- a/project/VS2010Express/XBMC.vcxproj.filters +++ b/project/VS2010Express/XBMC.vcxproj.filters @@ -1420,9 +1420,6 @@ settings - - settings - settings @@ -2922,9 +2919,6 @@ settings\dialogs - - settings\windows - settings\windows @@ -2991,6 +2985,51 @@ filesystem\MusicDatabaseDirectory + + settings\windows + + + settings + + + settings + + + settings + + + settings + + + settings + + + settings + + + settings + + + network + + + utils + + + settings + + + settings + + + settings + + + settings + + + settings + @@ -4321,9 +4360,6 @@ settings - - settings - settings @@ -5756,9 +5792,6 @@ settings\dialogs - - settings\windows - settings\windows @@ -5846,6 +5879,60 @@ filesystem\MusicDatabaseDirectory + + settings\windows + + + settings + + + settings + + + settings + + + settings + + + settings + + + settings + + + settings + + + settings + + + network + + + utils + + + utils + + + settings + + + settings + + + settings + + + settings + + + settings + + + settings + @@ -5877,4 +5964,4 @@ interfaces\swig - + \ No newline at end of file diff --git a/system/settings/android.xml b/system/settings/android.xml new file mode 100644 index 0000000000000..2982b93678cf3 --- /dev/null +++ b/system/settings/android.xml @@ -0,0 +1,10 @@ + + +
+ + + false + + +
+
diff --git a/system/settings/darwin.xml b/system/settings/darwin.xml new file mode 100644 index 0000000000000..419e6090bf245 --- /dev/null +++ b/system/settings/darwin.xml @@ -0,0 +1,61 @@ + + +
+ + + + + + + + + false + + + false + + + false + + + + + + + 1 + 1 + + + + + + + + + + + 4 + false + + + 0 + + + + + 1 + 500 + + 50 + 50 + 1000 + 14046 + + 2 + + + + + +
+
diff --git a/system/settings/darwin_ios.xml b/system/settings/darwin_ios.xml new file mode 100644 index 0000000000000..f13e5ea2170ac --- /dev/null +++ b/system/settings/darwin_ios.xml @@ -0,0 +1,53 @@ + + +
+ + + + 4 + + + 4 + + + +
+
+ + + + false + + + + + + + IsAppleTV2 + + + IsAppleTV2 + + + false + + + + + Default + + + 4 + Default + + + + + + + 4 + + + +
+
diff --git a/system/settings/darwin_ios_atv2.xml b/system/settings/darwin_ios_atv2.xml new file mode 100644 index 0000000000000..3ecdcd32ef5b1 --- /dev/null +++ b/system/settings/darwin_ios_atv2.xml @@ -0,0 +1,15 @@ + + +
+ + + + false + + + false + + + +
+
diff --git a/system/settings/darwin_osx.xml b/system/settings/darwin_osx.xml new file mode 100644 index 0000000000000..2d839d6ff1eb8 --- /dev/null +++ b/system/settings/darwin_osx.xml @@ -0,0 +1,12 @@ + + +
+ + + + 1 + + + +
+
diff --git a/system/settings/freebsd.xml b/system/settings/freebsd.xml new file mode 100644 index 0000000000000..ccc0c81a0d12d --- /dev/null +++ b/system/settings/freebsd.xml @@ -0,0 +1,4 @@ + + + + diff --git a/system/settings/linux.xml b/system/settings/linux.xml new file mode 100644 index 0000000000000..fd8867ebc39aa --- /dev/null +++ b/system/settings/linux.xml @@ -0,0 +1,12 @@ + + +
+ + + + false + + + +
+
diff --git a/system/settings/rbp.xml b/system/settings/rbp.xml new file mode 100644 index 0000000000000..daa27f3713d1c --- /dev/null +++ b/system/settings/rbp.xml @@ -0,0 +1,38 @@ + +
+ + + + false + + + + + + + 2 + + + false + + + false + + + false + + + false + + + + false + + + + false + + + +
+
diff --git a/system/settings/settings.xml b/system/settings/settings.xml new file mode 100644 index 0000000000000..7045071ba4649 --- /dev/null +++ b/system/settings/settings.xml @@ -0,0 +1,2426 @@ + + +
+ + + + 0 + skin.confluence + xbmc.gui.skin + + + 0 + + + + + + + + 1 + SKINDEFAULT + + skinthemes + + + + + 1 + SKINDEFAULT + + skincolors + + + + + 1 + Default + + skinfonts + + + + + 2 + 0 + + -20 + 2 + 20 + 14047 + + + + + 0 + 10000 + + startupwindows + + + + + 0 + SKINDEFAULT + + skinsounds + + + + + + + 1 + true + + + 1 + + true + + + true + + + + + + + + + 0 + English + + languages + + + + + 0 + USA (12h) + + regions + + + + + + + + + 1 + DEFAULT + + charsets + + + + + + + + + + + 2 + default + + timezonecountries + + + + + 2 + default + + timezones + + + + + + + + + + + 1 + original + + streamlanguages + + + + + 1 + original + + streamlanguages + + + + + + + + + 1 + true + + + 1 + true + + + 1 + true + + + 1 + false + + + + + + + + + + + + + 1 + true + + + + + + + + + + + + + 1 + false + + + + + + + 0 + screensaver.xbmc.builtin.dim + xbmc.ui.screensaver + true + + + + + + 0 + + + + + + + + + + + + + 0 + + + + + + + + 0 + 3 + + 1 + 1 + 60 + 14044 + + + + + + + + + + + 1 + true + + + + + + + + 1 + true + + + + + screensaver.xbmc.builtin.dim + + + + + + + + + + false + + + 4 + 720 + + + 4 + 480 + + + +
+
+ + + + 4 + true + + + 0 + true + + + 4 + true + + + 1 + true + + + 1 + 1 + + + + + + + + + + + 0 + false + + + 1 + false + + + 1 + false + + + + + 2 + + + 2 + + + 2 + + + + + + + 1 + false + + + + + 2 + 0 + + rendermethods + + + + + 2 + 0 + + 0 + 10 + 100 + 14047 + + + + + HAVE_LIBVDPAU + 2 + true + + + HAVE_LIBVA + 2 + true + + + HasDXVA2 + 2 + true + + + HasCrystalHDDevice + 2 + true + + + HasVDADecoder + 2 + true + + + HAVE_LIBOPENMAX + 2 + true + + + HasVideoToolBoxDecoder + 2 + true + + + HAS_GL + 4 + true + + + 2 + 0 + + + + + + + + + + + 2 + 0 + + refreshchangedelays + + + + 0 + + + + + 2 + false + + + 2 + 2 + + + + + + + + + + true + + + + + 4 + 5.0 + + 0.0 + 0.1 + 10.0 + + + + + + true + 2 + + + + + + + 4 + 1 + + + + + + + + + + + + + true + 2 + + + + + + + 2 + 0 + + 0 + 1 + 20 + 14047 + + + + + 1 + 0 + + + + + + + + + + + + HAVE_LIBVDPAU + 4 + false + + + + + + + HAS_GL + HAS_GLESv2 + + HAVE_LIBVDPAU + + + + 4 + false + + + + + 1 + true + + + 1 + true + + + + + + + 1 + 1 + + + + + + + + + + + + 1 + true + + + 1 + true + + + 4 + true + + + + + 4 + 100024 + + + 4 + false + + + 4 + false + + + + + + + 1 + arial.ttf + + fonts + + + + + 1 + 28 + + 16 + 2 + 74 + + + + + + + + + 1 + 1 + + + + + + + + + + + + + + + + 1 + 1 + + + + + + + + + + + + + + + + + + + + 1 + DEFAULT + + charsets + + + + + + + + + 1 + false + + + + + 1 + + true + 657 + + false + + videos + + + + + + 1 + 0 + + + + + + + + + + + + + + + + + 0 + false + + + 2 + 0 + + 0 + 1 + 8 + + + + + 1 + false + + + + + false + + + 4 + metadata.themoviedb.org + xbmc.metadata.scraper.movies + + + 4 + metadata.tvdb.com + xbmc.metadata.scraper.tvshows + + + 4 + metadata.musicvideos.theaudiodb.com + xbmc.metadata.scraper.musicvideos + + + + + + +
+
+ + + + 1 + false + + + + + 1 + true + + + 2 + true + + + 2 + false + + + + + 1 + + + true + + + + + 1 + + + true + + + + + 2 + + + + + 1 + false + + + + + + + 1 + true + + + 1 + true + + + 1 + false + + + 1 + 5 + + 1 + 1 + 10 + 14045 + + + + + + + 1 + + true + 657 + + false + + + + + 1 + + + true + + + + + + + + + 1 + 3 + + 0 + 1 + 3 + epgguideviews + + + + + 1 + 3 + + 1 + 1 + 14 + 17999 + + + + + + + 1 + 120 + + 15 + 15 + 2880 + 14044 + + + + + 1 + false + + + 1 + false + + + 1 + true + + + 1 + + + + + + + 1 + true + + + 1 + 0 + + 0 + 1 + 2 + pvrstartlastchannel + + + + + 1 + true + + + + + 1 + 10 + + 1 + 1 + 60 + 14045 + + + + + 1 + false + + + 1 + 0 + + 0 + 250 + 10000 + 14046 + + + + + + + + + 1 + 120 + + 1 + 1 + 720 + 14044 + + + + + 1 + 50 + + 1 + 1 + 100 + + + + + 1 + 99 + + 1 + 1 + 365 + 17999 + + + + + 1 + 0 + + 0 + 1 + 60 + 14044 + + + + + 1 + 0 + + 0 + 1 + 60 + 14044 + + + + + + + 1 + true + + + + + + + 1 + false + + + + + 1 + 15 + + 0 + 5 + 360 + 14044 + + + + + 1 + + true + + + + 1 + 15 + + 0 + 1 + 60 + 14044 + + + + + + + 1 + false + + + 1 + 00:00:00 + + + + + + CheckPVRParentalPin + + + 1 + false + + + + + 1 + + true + + + true + + + + + 1 + 300 + + 5 + 5 + 1200 + 14045 + + + + true + + + + + + + + + 1 + + + +
+
+ + + + 4 + true + + + 1 + true + + + + + 0 + false + + + 1 + metadata.album.universal + xbmc.metadata.scraper.albums + + + 1 + metadata.artists.universal + xbmc.metadata.scraper.artists + + + 1 + false + + + 1 + false + + + + + 2 + + + 2 + + + 2 + + + + + + + 0 + true + + + 1 + false + + + + + 2 + 1 + + + + + + + + + + + 2 + 89 + + 77 + 1 + 101 + 14050 + + + + + 2 + 89 + + 77 + 1 + 101 + 14050 + + + + + 2 + false + + + + + 1 + 0 + + 0 + 1 + 15 + 14045 + + + + + 1 + true + + + + + 0 + + + + + + + + + 0 + visualization.glspectrum + xbmc.player.musicviz + true + + + + + + + 0 + true + + + 2 + [%N. ]%A - %T + 16016 + + + + 2 + %D + 16016 + + + + 4 + + true + 16016 + + + + 4 + + true + 16016 + + + + 4 + + true + 16016 + + + + 4 + + true + 16016 + + + + 0 + true + + + + + + + 1 + 0 + + audiocdactions + + + + + 1 + true + + + + + 1 + + true + 657 + + + + 2 + %A - %B/[%N. ][%A - ]%T + 16016 + + + + 2 + 3 + + audiocdencoders + + + + + 2 + 0 + + + + + + + + + + + + + 2 + 3 + + + + + + + 2 + 192 + + 128 + 32 + 320 + 14048 + + + + + + 2 + 3 + 0 + + + + + + + 2 + 5 + + 0 + 1 + 8 + + + + 3 + + + + + 1 + true + + + + + HAS_KARAOKE + + + 2 + false + + + 2 + false + + + true + + + + + + + 2 + arial.ttf + + fonts + + + + true + + + + + 2 + 36 + + 16 + 2 + 74 + + + + true + + + + + + 2 + 0 + + + + + + + + + + + true + + + + + 2 + DEFAULT + + charsets + + + + true + + + + + + + 2 + + + true + + + + + 2 + + + true + + + + + + + + + 4 + 10501 + + + 4 + false + + + 4 + + true + + + +
+
+ + + + 0 + true + + + 1 + true + + + 1 + true + + + 1 + true + + + false + 1 + 14 + + resolutions + + + + + + + + + 0 + 5 + + 1 + 1 + 100 + 14045 + + + + + 0 + true + + + 2 + false + + + +
+
+ + + + 4 + 0 + + 0 + 1 + 2 + + + + + 0 + weather.wunderground + xbmc.python.weather + + + 0 + + + + + + + + +
+
+ + + + 0 + XBMC + + + + + + + + 0 + false + + + 2 + true + + + true + + + + + 1 + false + + + 1 + false + + + + + HAS_WEB_SERVER + + + 1 + false + + + 2 + 8080 + 730 + + 1 + 1 + 65535 + + + + true + + + + + 2 + xbmc + true + + + true + + + + + 2 + + true + 730 + + + true + + + + + 1 + webinterface.default + xbmc.gui.webinterface + + + + + + + HAS_EVENT_SERVER + HAS_JSONRPC + + + + + 1 + true + + + HAS_EVENT_SERVER + 4 + 9777 + + 1 + 1 + 65535 + + + + true + + + + + HAS_EVENT_SERVER + 4 + 10 + + 1 + 1 + 100 + + + + true + + + + + HAS_EVENT_SERVER + 4 + 20 + + 1 + 1 + 100 + + + + true + + + + + 1 + false + + + true + + + + + HAS_EVENT_SERVER + 4 + 750 + + 5 + 5 + 10000 + + + + true + + + + + HAS_EVENT_SERVER + 4 + 25 + + 5 + 5 + 10000 + + + + true + + + + + + + HAS_ZEROCONF + + + 2 + true + + + + + HAS_AIRPLAY + + + 1 + false + + + 1 + false + + + true + + + + + 1 + + true + 733 + + + true + + + + + + + + + 2 + 0.0.0.0 + + + + 2 + WORKGROUP + 1202 + + + + +
+
+ + + + 0 + 0 + + screens + + + + + 0 + 0 + + resolutions + + + + -1 + + + + + + IsStandAlone + 0 + DESKTOP + + refreshrates + + + + + + + -1 + + + + + + + 2 + true + + + -1 + + + + + 1 + false + + + + + + + + + + 2 + 3 + + verticalsyncs + + + + + 1 + + + HAS_GL + 1 + + + + + HAS_GL + HAS_DX + + + 3 + false + + videoplayer.vdpaustudiolevel + + + + + + + + 1 + 0 + + audiooutputmodes + + + + + 0 + 1 + + + + + + + + + + + + + + + + audiooutput.channellayout + + + + + 2 + true + + + 2 + false + + + 2 + true + + + + + 1 + 2 + + + + + + + 2 + true + + + + + 1 + 2 + + + + + + + 2 + false + + + + + 1 + 2 + + + + + + + 2 + true + + + 2 + + + + + 2 + true + + + 2 + + + + + 2 + true + + + + + true + 2 + + + + + + + + + 2 + Default + + audiodevices + + + + + 2 + Default + + audiodevicespassthrough + + + + + + 1 + 2 + + + + + + + + + 0 + 1 + + + + + + + + + + + + + + + 2 + + + + + + + + + + 2 + false + + + 0 + true + + + HAS_SDL_JOYSTICK + 0 + true + + + + + + + 1 + false + + + 1 + 0 + + + + + + + + + + + + true + + + + + 1 + + true + + + true + + + + + 1 + 8080 + 707 + + 1 + 1 + 65535 + + + + true + + + + + 1 + + true + + + true + + + + + 1 + + true + + + true + + + + + + + 2 + 0 + + 0 + 512 + 102400 + 14048 + + + + + + + + + 0 + 0 + + 0 + 5 + 120 + 14044 + + + + + 2 + 0 + + 0 + 5 + 120 + 14044 + + + + + 2 + 0 + + shutdownstates + + + + + + + + + 2 + false + + + 2 + + true + 657 + + + + + + CheckMasterLock + + + 2 + - + + + + 2 + false + + + 0 + + + + + 4 + 3 + + 3 + 1 + 100 + + + + + + + false + + + 4 + 256 + + 0 + 256 + 4096 + 14049 + + + + + + + 4 + 2048 + + 0 + 256 + 16384 + 14049 + + + + + 4 + 2048 + + 0 + 256 + 16384 + 14049 + + + + + 4 + 4096 + + 0 + 256 + 16384 + 14049 + + + + + + + 4 + 256 + + 0 + 256 + 4096 + 14049 + + + + + 4 + 256 + + 0 + 256 + 4096 + 14049 + + + + + 4 + 256 + + 0 + 256 + 4096 + 14049 + + + + + + + 4 + 2048 + + 0 + 256 + 16384 + 14049 + + + + + 4 + 2048 + + 0 + 256 + 16384 + 14049 + + + + + + + 4 + 4096 + + 0 + 256 + 16384 + 14049 + + + + + + + + + 4 + + true + + + + + + + 4 + true + + + 4 + true + + + 4 + false + + + +
+
diff --git a/system/settings/win32.xml b/system/settings/win32.xml new file mode 100644 index 0000000000000..0daee415ef18e --- /dev/null +++ b/system/settings/win32.xml @@ -0,0 +1,43 @@ + + +
+ + + false + + +
+
+ + + + HAS_GL + + + HAS_GL + + + +
+
+ + + + false + + + + + false + +
+
+ + + + HAS_GL + + + +
+
diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp index af8c74290029d..a362a51f58c9a 100644 --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp @@ -37,18 +37,7 @@ #include "PlayListPlayer.h" #include "Autorun.h" #include "video/Bookmark.h" -#ifdef HAS_WEB_SERVER -#include "network/WebServer.h" -#include "network/httprequesthandler/HTTPImageHandler.h" -#include "network/httprequesthandler/HTTPVfsHandler.h" -#ifdef HAS_JSONRPC -#include "network/httprequesthandler/HTTPJsonRpcHandler.h" -#endif -#ifdef HAS_WEB_INTERFACE -#include "network/httprequesthandler/HTTPWebinterfaceHandler.h" -#include "network/httprequesthandler/HTTPWebinterfaceAddonsHandler.h" -#endif -#endif +#include "network/NetworkServices.h" #include "guilib/GUIControlProfiler.h" #include "utils/LangCodeExpander.h" #include "GUIInfoManager.h" @@ -94,12 +83,14 @@ #include "windowing/WindowingFactory.h" #include "powermanagement/PowerManager.h" #include "powermanagement/DPMSSupport.h" +#include "settings/SettingAddon.h" #include "settings/Settings.h" #include "settings/AdvancedSettings.h" #include "settings/DisplaySettings.h" #include "settings/MediaSettings.h" #include "settings/MediaSourceSettings.h" #include "settings/SkinSettings.h" +#include "settings/Settings.h" #include "guilib/LocalizeStrings.h" #include "utils/CPUInfo.h" #include "utils/RssManager.h" @@ -319,10 +310,16 @@ #include "utils/JobManager.h" #include "utils/SaveFileStateJob.h" #include "utils/AlarmClock.h" +#include "utils/RssReader.h" #include "utils/StringUtils.h" #include "utils/Weather.h" #include "DatabaseManager.h" +#include "settings/DisplaySettings.h" +#include "settings/MediaSettings.h" +#include "settings/SkinSettings.h" +#include "view/ViewStateSettings.h" + #ifdef _LINUX #include "XHandle.h" #endif @@ -344,6 +341,10 @@ #include "android/activity/XBMCApp.h" #endif +#ifdef TARGET_LINUX +#include "linux/LinuxTimezone.h" +#endif + using namespace std; using namespace ADDON; using namespace XFILE; @@ -375,18 +376,6 @@ using namespace XbmcThreads; //extern IDirectSoundRenderer* m_pAudioDecoder; CApplication::CApplication(void) : m_pPlayer(NULL) -#ifdef HAS_WEB_SERVER - , m_WebServer(*new CWebServer) - , m_httpImageHandler(*new CHTTPImageHandler) - , m_httpVfsHandler(*new CHTTPVfsHandler) -#ifdef HAS_JSONRPC - , m_httpJsonRpcHandler(*new CHTTPJsonRpcHandler) -#endif -#ifdef HAS_WEB_INTERFACE - , m_httpWebinterfaceHandler(*new CHTTPWebinterfaceHandler) - , m_httpWebinterfaceAddonsHandler(*new CHTTPWebinterfaceAddonsHandler) -#endif -#endif , m_itemCurrentFile(new CFileItem) , m_stackFileItemToUpdate(new CFileItem) , m_progressTrackingVideoResumeBookmark(*new CBookmark) @@ -453,18 +442,6 @@ CApplication::CApplication(void) CApplication::~CApplication(void) { -#ifdef HAS_WEB_SERVER - delete &m_WebServer; - delete &m_httpImageHandler; - delete &m_httpVfsHandler; -#ifdef HAS_JSONRPC - delete &m_httpJsonRpcHandler; -#endif -#ifdef HAS_WEB_INTERFACE - delete &m_httpWebinterfaceHandler; - delete &m_httpWebinterfaceAddonsHandler; -#endif -#endif delete m_musicInfoScanner; delete m_videoInfoScanner; delete &m_progressTrackingVideoResumeBookmark; @@ -510,9 +487,9 @@ bool CApplication::OnEvent(XBMC_Event& newEvent) { g_Windowing.SetWindowResolution(newEvent.resize.w, newEvent.resize.h); g_graphicsContext.SetVideoResolution(RES_WINDOW, true); - g_guiSettings.SetInt("window.width", newEvent.resize.w); - g_guiSettings.SetInt("window.height", newEvent.resize.h); - g_settings.Save(); + CSettings::Get().SetInt("window.width", newEvent.resize.w); + CSettings::Get().SetInt("window.height", newEvent.resize.h); + CSettings::Get().Save(); } break; case XBMC_VIDEOMOVE: @@ -665,6 +642,7 @@ bool CApplication::Create() init_emu_environ(); CProfilesManager::Get().Load(); + CSpecialProtocol::SetProfilePath(CProfilesManager::Get().GetProfileUserDataFolder()); CLog::Log(LOGNOTICE, "-----------------------------------------------------------------------"); #if defined(TARGET_DARWIN_OSX) @@ -735,36 +713,25 @@ bool CApplication::Create() return false; } + // Initialize default Settings - don't move CLog::Log(LOGNOTICE, "load settings..."); - g_settings.RegisterSettingsHandler(this); - g_settings.RegisterSettingsHandler(&CProfilesManager::Get()); - g_settings.RegisterSettingsHandler(&g_advancedSettings); - g_settings.RegisterSettingsHandler(&CMediaSourceSettings::Get()); - g_settings.RegisterSettingsHandler(&CPlayerCoreFactory::Get()); - g_settings.RegisterSettingsHandler(&CRssManager::Get()); -#ifdef HAS_UPNP - g_settings.RegisterSettingsHandler(&CUPnPSettings::Get()); -#endif - - g_settings.RegisterSubSettings(this); - g_settings.RegisterSubSettings(&CDisplaySettings::Get()); - g_settings.RegisterSubSettings(&CMediaSettings::Get()); - g_settings.RegisterSubSettings(&CSkinSettings::Get()); - g_settings.RegisterSubSettings(&g_sysinfo); - g_settings.RegisterSubSettings(&CViewStateSettings::Get()); - - g_guiSettings.Initialize(); // Initialize default Settings - don't move + if (!CSettings::Get().Initialize()) + return false; + g_powerManager.SetDefaults(); - if (!g_settings.Load()) + + // load the actual values + if (!CSettings::Get().Load()) { - CLog::Log(LOGFATAL, "%s: Failed to reset settings", __FUNCTION__); + CLog::Log(LOGFATAL, "unable to load settings"); return false; } + CSettings::Get().SetLoaded(); CLog::Log(LOGINFO, "creating subdirectories"); CLog::Log(LOGINFO, "userdata folder: %s", CProfilesManager::Get().GetProfileUserDataFolder().c_str()); - CLog::Log(LOGINFO, "recording folder: %s", g_guiSettings.GetString("audiocds.recordingpath",false).c_str()); - CLog::Log(LOGINFO, "screenshots folder: %s", g_guiSettings.GetString("debug.screenshotpath",false).c_str()); + CLog::Log(LOGINFO, "recording folder: %s", CSettings::Get().GetString("audiocds.recordingpath").c_str()); + CLog::Log(LOGINFO, "screenshots folder: %s", CSettings::Get().GetString("debug.screenshotpath").c_str()); CDirectory::Create(CProfilesManager::Get().GetUserDataFolder()); CDirectory::Create(CProfilesManager::Get().GetProfileUserDataFolder()); CProfilesManager::Get().CreateProfileFolders(); @@ -775,7 +742,7 @@ bool CApplication::Create() g_charsetConverter.reset(); // Load the langinfo to have user charset <-> utf-8 conversion - CStdString strLanguage = g_guiSettings.GetString("locale.language"); + CStdString strLanguage = CSettings::Get().GetString("locale.language"); strLanguage[0] = toupper(strLanguage[0]); CStdString strLangInfoPath; @@ -803,7 +770,7 @@ bool CApplication::Create() // restore AE's previous volume state SetHardwareVolume(m_volumeLevel); CAEFactory::SetMute (m_muted); - CAEFactory::SetSoundMode(g_guiSettings.GetInt("audiooutput.guisoundmode")); + CAEFactory::SetSoundMode(CSettings::Get().GetInt("audiooutput.guisoundmode")); // initialize the addon database (must be before the addon manager is init'd) CDatabaseManager::Get().Initialize(true); @@ -821,7 +788,7 @@ bool CApplication::Create() // Create the Mouse, Keyboard, Remote, and Joystick devices // Initialize after loading settings to get joystick deadzone setting g_Mouse.Initialize(); - g_Mouse.SetEnabled(g_guiSettings.GetBool("input.enablemouse")); + g_Mouse.SetEnabled(CSettings::Get().GetBool("input.enablemouse")); g_Keyboard.Initialize(); #if defined(HAS_LIRC) || defined(HAS_IRSERVERSUITE) @@ -911,7 +878,7 @@ bool CApplication::CreateGUI() } // update the window resolution - g_Windowing.SetWindowResolution(g_guiSettings.GetInt("window.width"), g_guiSettings.GetInt("window.height")); + g_Windowing.SetWindowResolution(CSettings::Get().GetInt("window.width"), CSettings::Get().GetInt("window.height")); if (g_advancedSettings.m_startFullScreen && CDisplaySettings::Get().GetCurrentResolution() == RES_WINDOW) CDisplaySettings::Get().SetCurrentResolution(RES_DESKTOP); @@ -1263,25 +1230,13 @@ bool CApplication::Initialize() // initialize (and update as needed) our databases CDatabaseManager::Get().Initialize(); -#ifdef HAS_WEB_SERVER - CWebServer::RegisterRequestHandler(&m_httpImageHandler); - CWebServer::RegisterRequestHandler(&m_httpVfsHandler); -#ifdef HAS_JSONRPC - CWebServer::RegisterRequestHandler(&m_httpJsonRpcHandler); -#endif -#ifdef HAS_WEB_INTERFACE - CWebServer::RegisterRequestHandler(&m_httpWebinterfaceAddonsHandler); - CWebServer::RegisterRequestHandler(&m_httpWebinterfaceHandler); -#endif -#endif - StartServices(); // Init DPMS, before creating the corresponding setting control. m_dpms = new DPMSSupport(); if (g_windowManager.Initialized()) { - g_guiSettings.GetSetting("powermanagement.displaysoff")->SetVisible(m_dpms->IsSupported()); + CSettings::Get().GetSetting("powermanagement.displaysoff")->SetVisible(m_dpms->IsSupported()); g_windowManager.Add(new CGUIWindowHome); g_windowManager.Add(new CGUIWindowPrograms); @@ -1399,16 +1354,17 @@ bool CApplication::Initialize() /* window id's 3000 - 3100 are reserved for python */ // Make sure we have at least the default skin - if (!LoadSkin(g_guiSettings.GetString("lookandfeel.skin")) && !LoadSkin(DEFAULT_SKIN)) + string defaultSkin = ((const CSettingString*)CSettings::Get().GetSetting("lookandfeel.skin"))->GetDefault(); + if (!LoadSkin(CSettings::Get().GetString("lookandfeel.skin")) && !LoadSkin(defaultSkin)) { - CLog::Log(LOGERROR, "Default skin '%s' not found! Terminating..", DEFAULT_SKIN); - return false; + CLog::Log(LOGERROR, "Default skin '%s' not found! Terminating..", defaultSkin.c_str()); + return false; } if (g_advancedSettings.m_splashImage) SAFE_DELETE(m_splash); - if (g_guiSettings.GetBool("masterlock.startuplock") && + if (CSettings::Get().GetBool("masterlock.startuplock") && CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !CProfilesManager::Get().GetMasterProfile().getLockCode().IsEmpty()) { @@ -1474,7 +1430,7 @@ bool CApplication::Initialize() ResetScreenSaver(); #ifdef HAS_SDL_JOYSTICK - g_Joystick.SetEnabled(g_guiSettings.GetBool("input.enablejoystick") && + g_Joystick.SetEnabled(CSettings::Get().GetBool("input.enablejoystick") && CPeripheralImon::GetCountOfImonsConflictWithDInput() == 0 ); #endif @@ -1483,458 +1439,217 @@ bool CApplication::Initialize() bool CApplication::StartServer(enum ESERVERS eServer, bool bStart, bool bWait/* = false*/) { - bool ret = true; - bool oldSetting = false; - + bool ret = false; switch(eServer) { case ES_WEBSERVER: - oldSetting = g_guiSettings.GetBool("services.webserver"); - g_guiSettings.SetBool("services.webserver", bStart); - - if (bStart) - ret = StartWebServer(); - else - StopWebServer(); - - if (!ret) - { - g_guiSettings.SetBool("services.webserver", oldSetting); - } + // the callback will take care of starting/stopping webserver + ret = CSettings::Get().SetBool("services.webserver", bStart); break; - case ES_AIRPLAYSERVER: - oldSetting = g_guiSettings.GetBool("services.airplay"); - g_guiSettings.SetBool("services.airplay", bStart); - - if (bStart) - ret = StartAirplayServer(); - else - StopAirplayServer(bWait); - if (!ret) - { - g_guiSettings.SetBool("services.airplay", oldSetting); - } + case ES_AIRPLAYSERVER: + // the callback will take care of starting/stopping airplay + ret = CSettings::Get().SetBool("services.airplay", bStart); break; - case ES_JSONRPCSERVER: - oldSetting = g_guiSettings.GetBool("services.esenabled"); - g_guiSettings.SetBool("services.esenabled", bStart); - if (bStart) - ret = StartJSONRPCServer(); - else - StopJSONRPCServer(bWait); - - if (!ret) - { - g_guiSettings.SetBool("services.esenabled", oldSetting); - } + case ES_JSONRPCSERVER: + // the callback will take care of starting/stopping jsonrpc server + ret = CSettings::Get().SetBool("services.esenabled", bStart); break; + case ES_UPNPSERVER: - g_guiSettings.SetBool("services.upnpserver", bStart); - if (bStart) - StartUPnPServer(); - else - StopUPnPServer(); + // the callback will take care of starting/stopping upnp server + ret = CSettings::Get().SetBool("services.upnpserver", bStart); break; + case ES_UPNPRENDERER: - g_guiSettings.SetBool("services.upnprenderer", bStart); - if (bStart) - StartUPnPRenderer(); - else - StopUPnPRenderer(); + // the callback will take care of starting/stopping upnp renderer + ret = CSettings::Get().SetBool("services.upnprenderer", bStart); break; - case ES_EVENTSERVER: - oldSetting = g_guiSettings.GetBool("services.esenabled"); - g_guiSettings.SetBool("services.esenabled", bStart); - - if (bStart) - ret = StartEventServer(); - else - StopEventServer(bWait, false); - - if (!ret) - { - g_guiSettings.SetBool("services.esenabled", oldSetting); - } + case ES_EVENTSERVER: + // the callback will take care of starting/stopping event server + ret = CSettings::Get().SetBool("services.esenabled", bStart); break; + case ES_ZEROCONF: - g_guiSettings.SetBool("services.zeroconf", bStart); - if (bStart) - StartZeroconf(); - else - StopZeroconf(); + // the callback will take care of starting/stopping zeroconf + ret = CSettings::Get().SetBool("services.zeroconf", bStart); break; + default: ret = false; break; } - g_settings.Save(); + CSettings::Get().Save(); return ret; } -bool CApplication::StartWebServer() -{ -#ifdef HAS_WEB_SERVER - if (g_guiSettings.GetBool("services.webserver") && m_network->IsAvailable()) - { - int webPort = atoi(g_guiSettings.GetString("services.webserverport")); - CLog::Log(LOGNOTICE, "Webserver: Starting..."); -#ifdef _LINUX - if (webPort < 1024 && !CUtil::CanBindPrivileged()) - { - CLog::Log(LOGERROR, "Cannot start Web Server on port %i, no permission to bind to ports below 1024", webPort); - return false; - } -#endif - - bool started = false; - if (m_WebServer.Start(webPort, g_guiSettings.GetString("services.webserverusername"), g_guiSettings.GetString("services.webserverpassword"))) - { - std::vector > txt; - started = true; - // publish web frontend and API services -#ifdef HAS_WEB_INTERFACE - CZeroconf::GetInstance()->PublishService("servers.webserver", "_http._tcp", g_infoManager.GetLabel(SYSTEM_FRIENDLY_NAME), webPort, txt); -#endif -#ifdef HAS_JSONRPC - CZeroconf::GetInstance()->PublishService("servers.jsonrpc-http", "_xbmc-jsonrpc-h._tcp", g_infoManager.GetLabel(SYSTEM_FRIENDLY_NAME), webPort, txt); -#endif - } - - return started; - } -#endif - - return true; -} - -void CApplication::StopWebServer() -{ -#ifdef HAS_WEB_SERVER - if (m_WebServer.IsStarted()) - { - CLog::Log(LOGNOTICE, "Webserver: Stopping..."); - m_WebServer.Stop(); - if(! m_WebServer.IsStarted() ) - { - CLog::Log(LOGNOTICE, "Webserver: Stopped..."); - CZeroconf::GetInstance()->RemoveService("servers.webserver"); - CZeroconf::GetInstance()->RemoveService("servers.jsonrpc-http"); - } else - CLog::Log(LOGWARNING, "Webserver: Failed to stop."); - } -#endif -} - -bool CApplication::StartAirplayServer() +void CApplication::StartPVRManager(bool bOpenPVRWindow /* = false */) { - bool ret = false; -#ifdef HAS_AIRPLAY - if (g_guiSettings.GetBool("services.airplay") && m_network->IsAvailable()) - { - int listenPort = g_advancedSettings.m_airPlayPort; - CStdString password = g_guiSettings.GetString("services.airplaypassword"); - bool usePassword = g_guiSettings.GetBool("services.useairplaypassword"); - - if (CAirPlayServer::StartServer(listenPort, true)) - { - CAirPlayServer::SetCredentials(usePassword, password); - std::vector > txt; - CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface(); - if (iface) - { - txt.push_back(std::make_pair("deviceid", iface->GetMacAddress())); - } - else - { - txt.push_back(std::make_pair("deviceid", "FF:FF:FF:FF:FF:F2")); - } - txt.push_back(std::make_pair("features", "0x77")); - txt.push_back(std::make_pair("model", "Xbmc,1")); - txt.push_back(std::make_pair("srcvers", AIRPLAY_SERVER_VERSION_STR)); - CZeroconf::GetInstance()->PublishService("servers.airplay", "_airplay._tcp", g_infoManager.GetLabel(SYSTEM_FRIENDLY_NAME), listenPort, txt); - ret = true; - } - } - if (ret) -#endif - { -#ifdef HAS_AIRTUNES - if (g_guiSettings.GetBool("services.airplay") && m_network->IsAvailable()) - { - int listenPort = g_advancedSettings.m_airTunesPort; - CStdString password = g_guiSettings.GetString("services.airplaypassword"); - bool usePassword = g_guiSettings.GetBool("services.useairplaypassword"); - - if (!CAirTunesServer::StartServer(listenPort, true, usePassword, password)) - { - CLog::Log(LOGERROR, "Failed to start AirTunes Server"); - } - ret = true; - } -#endif - } - return ret; + if (CSettings::Get().GetBool("pvrmanager.enabled")) + g_PVRManager.Start(true, bOpenPVRWindow); } -void CApplication::StopAirplayServer(bool bWait) +void CApplication::StopPVRManager() { -#ifdef HAS_AIRPLAY - CAirPlayServer::StopServer(bWait); - CZeroconf::GetInstance()->RemoveService("servers.airplay"); -#endif -#ifdef HAS_AIRTUNES - CAirTunesServer::StopServer(bWait); -#endif + CLog::Log(LOGINFO, "stopping PVRManager"); + if (g_PVRManager.IsPlaying()) + StopPlaying(); + g_PVRManager.Stop(); + g_EpgContainer.Stop(); } -bool CApplication::StartJSONRPCServer() +void CApplication::StartServices() { -#ifdef HAS_JSONRPC - if (g_guiSettings.GetBool("services.esenabled")) - { - if (CTCPServer::StartServer(g_advancedSettings.m_jsonTcpPort, g_guiSettings.GetBool("services.esallinterfaces"))) - { - std::vector > txt; - CZeroconf::GetInstance()->PublishService("servers.jsonrpc-tcp", "_xbmc-jsonrpc._tcp", g_infoManager.GetLabel(SYSTEM_FRIENDLY_NAME), g_advancedSettings.m_jsonTcpPort, txt); - return true; - } - else - return false; - } +#if !defined(_WIN32) && defined(HAS_DVD_DRIVE) + // Start Thread for DVD Mediatype detection + CLog::Log(LOGNOTICE, "start dvd mediatype detection"); + m_DetectDVDType.Create(false, THREAD_MINSTACKSIZE); #endif - return true; -} - -void CApplication::StopJSONRPCServer(bool bWait) -{ -#ifdef HAS_JSONRPC - CTCPServer::StopServer(bWait); - CZeroconf::GetInstance()->RemoveService("servers.jsonrpc-tcp"); -#endif + CLog::Log(LOGNOTICE, "initializing playlistplayer"); + g_playlistPlayer.SetRepeat(PLAYLIST_MUSIC, CMediaSettings::Get().DoesMusicPlaylistRepeat() ? PLAYLIST::REPEAT_ALL : PLAYLIST::REPEAT_NONE); + g_playlistPlayer.SetShuffle(PLAYLIST_MUSIC, CMediaSettings::Get().IsMusicPlaylistShuffled()); + g_playlistPlayer.SetRepeat(PLAYLIST_VIDEO, CMediaSettings::Get().DoesVideoPlaylistRepeat() ? PLAYLIST::REPEAT_ALL : PLAYLIST::REPEAT_NONE); + g_playlistPlayer.SetShuffle(PLAYLIST_VIDEO, CMediaSettings::Get().IsVideoPlaylistShuffled()); + CLog::Log(LOGNOTICE, "DONE initializing playlistplayer"); } -void CApplication::StartUPnP() +void CApplication::StopServices() { -#ifdef HAS_UPNP - StartUPnPClient(); - StartUPnPServer(); - StartUPnPRenderer(); -#endif -} + m_network->NetworkMessage(CNetwork::SERVICES_DOWN, 0); -void CApplication::StopUPnP(bool bWait) -{ -#ifdef HAS_UPNP - if (UPNP::CUPnP::IsInstantiated()) - { - CLog::Log(LOGNOTICE, "stopping upnp"); - UPNP::CUPnP::ReleaseInstance(bWait); - } +#if !defined(_WIN32) && defined(HAS_DVD_DRIVE) + CLog::Log(LOGNOTICE, "stop dvd detect media"); + m_DetectDVDType.StopThread(); #endif -} -bool CApplication::StartEventServer() -{ -#ifdef HAS_EVENT_SERVER - CEventServer* server = CEventServer::GetInstance(); - if (!server) - { - CLog::Log(LOGERROR, "ES: Out of memory"); - return false; - } - if (g_guiSettings.GetBool("services.esenabled")) - { - CLog::Log(LOGNOTICE, "ES: Starting event server"); - server->StartServer(); - return true; - } -#endif - return true; + g_peripherals.Clear(); } -bool CApplication::StopEventServer(bool bWait, bool promptuser) +void CApplication::OnSettingChanged(const CSetting *setting) { -#ifdef HAS_EVENT_SERVER - CEventServer* server = CEventServer::GetInstance(); - if (!server) - { - CLog::Log(LOGERROR, "ES: Out of memory"); - return false; - } - if (promptuser) - { - if (server->GetNumberOfClients() > 0) - { - bool cancelled = false; - if (!CGUIDialogYesNo::ShowAndGetInput(13140, 13141, 13142, 20022, - -1, -1, cancelled, 10000) - || cancelled) - { - CLog::Log(LOGNOTICE, "ES: Not stopping event server"); - return false; - } - } - CLog::Log(LOGNOTICE, "ES: Stopping event server with confirmation"); + if (setting == NULL) + return; - CEventServer::GetInstance()->StopServer(true); + const std::string &settingId = setting->GetId(); + if (settingId == "lookandfeel.skin" || + settingId == "lookandfeel.font" || + settingId == "lookandfeel.skincolors") + ReloadSkin(); + else if (settingId == "lookandfeel.skintheme") + { + // also set the default color theme + string colorTheme = URIUtils::ReplaceExtension(((CSettingString*)setting)->GetValue(), ".xml"); + if (StringUtils::EqualsNoCase(colorTheme, "Textures.xml")) + colorTheme = "defaults.xml"; + + // check if we have to change the skin color + // if yes, it will trigger a call to ReloadSkin() in + // it's OnSettingChanged() callback + // if no we have to call ReloadSkin() ourselves + if (!StringUtils::EqualsNoCase(colorTheme, CSettings::Get().GetString("lookandfeel.skincolors"))) + CSettings::Get().SetString("lookandfeel.skincolors", colorTheme); + else + ReloadSkin(); } - else + else if (settingId == "lookandfeel.skinzoom") + g_windowManager.SendMessage(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_WINDOW_RESIZE); + else if (StringUtils::StartsWith(settingId, "audiooutput.")) { - if (!bWait) - CLog::Log(LOGNOTICE, "ES: Stopping event server"); + if (settingId == "audiooutput.guisoundmode") + CAEFactory::SetSoundMode(((CSettingInt*)setting)->GetValue()); - CEventServer::GetInstance()->StopServer(bWait); + CAEFactory::OnSettingsChange(settingId); } - - return true; -#endif + else if (StringUtils::EqualsNoCase(settingId, "musicplayer.replaygaintype")) + m_replayGainSettings.iType = ((CSettingInt*)setting)->GetValue(); + else if (StringUtils::EqualsNoCase(settingId, "musicplayer.replaygainpreamp")) + m_replayGainSettings.iPreAmp = ((CSettingInt*)setting)->GetValue(); + else if (StringUtils::EqualsNoCase(settingId, "musicplayer.replaygainnogainpreamp")) + m_replayGainSettings.iNoGainPreAmp = ((CSettingInt*)setting)->GetValue(); + else if (StringUtils::EqualsNoCase(settingId, "musicplayer.replaygainavoidclipping")) + m_replayGainSettings.bAvoidClipping = ((CSettingBool*)setting)->GetValue(); } -void CApplication::RefreshEventServer() +void CApplication::OnSettingAction(const CSetting *setting) { -#ifdef HAS_EVENT_SERVER - if (g_guiSettings.GetBool("services.esenabled")) - { - CEventServer::GetInstance()->RefreshSettings(); - } -#endif -} + if (setting == NULL) + return; -void CApplication::StartUPnPClient() -{ -#ifdef HAS_UPNP - if (g_guiSettings.GetBool("services.upnpcontroller")) + const std::string &settingId = setting->GetId(); + if (settingId == "lookandfeel.skinsettings") + g_windowManager.ActivateWindow(WINDOW_SKIN_SETTINGS); + else if (settingId == "screensaver.preview") + ActivateScreenSaver(true); + else if (settingId == "screensaver.settings") { - CLog::Log(LOGNOTICE, "starting upnp client"); - UPNP::CUPnP::GetInstance()->StartClient(); + AddonPtr addon; + if (CAddonMgr::Get().GetAddon(CSettings::Get().GetString("screensaver.mode"), addon, ADDON_SCREENSAVER)) + CGUIDialogAddonSettings::ShowAndGetInput(addon); } -#endif + else if (settingId == "videoscreen.guicalibration") + g_windowManager.ActivateWindow(WINDOW_SCREEN_CALIBRATION); + else if (settingId == "videoscreen.testpattern") + g_windowManager.ActivateWindow(WINDOW_TEST_PATTERN); } -void CApplication::StopUPnPClient() +bool CApplication::OnSettingUpdate(CSetting* &setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) { -#ifdef HAS_UPNP - if (UPNP::CUPnP::IsInstantiated()) - { - CLog::Log(LOGNOTICE, "stopping upnp client"); - UPNP::CUPnP::GetInstance()->StopClient(); - } -#endif -} + if (setting == NULL) + return false; -void CApplication::StartUPnPRenderer() -{ -#ifdef HAS_UPNP - if (g_guiSettings.GetBool("services.upnprenderer")) + const std::string &settingId = setting->GetId(); + if (settingId == "audiooutput.channels") { - CLog::Log(LOGNOTICE, "starting upnp renderer"); - UPNP::CUPnP::GetInstance()->StartRenderer(); - } -#endif -} + // check if this is an update from Eden + if (oldSettingId != NULL && oldSettingNode != NULL && + StringUtils::EqualsNoCase(oldSettingId, "audiooutput.channellayout")) + { + bool ret = false; + CSettingInt* channels = (CSettingInt*)setting; + if (channels->FromString(oldSettingNode->FirstChild()->ValueStr()) && channels->GetValue() < AE_CH_LAYOUT_MAX - 1) + ret = channels->SetValue(channels->GetValue() + 1); -void CApplication::StopUPnPRenderer() -{ -#ifdef HAS_UPNP - if (UPNP::CUPnP::IsInstantiated()) - { - CLog::Log(LOGNOTICE, "stopping upnp renderer"); - UPNP::CUPnP::GetInstance()->StopRenderer(); - } -#endif -} + // let's just reset the audiodevice settings as well + std::string audiodevice = CSettings::Get().GetString("audiooutput.audiodevice"); + CAEFactory::VerifyOutputDevice(audiodevice, false); + ret |= CSettings::Get().SetString("audiooutput.audiodevice", audiodevice.c_str()); -void CApplication::StartUPnPServer() -{ -#ifdef HAS_UPNP - if (g_guiSettings.GetBool("services.upnpserver")) - { - CLog::Log(LOGNOTICE, "starting upnp server"); - UPNP::CUPnP::GetInstance()->StartServer(); - } -#endif -} - -void CApplication::StopUPnPServer() -{ -#ifdef HAS_UPNP - if (UPNP::CUPnP::IsInstantiated()) - { - CLog::Log(LOGNOTICE, "stopping upnp server"); - UPNP::CUPnP::GetInstance()->StopServer(); + return ret; + } } -#endif -} - -void CApplication::StartZeroconf() -{ -#ifdef HAS_ZEROCONF - //entry in guisetting only present if HAS_ZEROCONF is set - if(g_guiSettings.GetBool("services.zeroconf")) + else if (settingId == "screensaver.mode") { - CLog::Log(LOGNOTICE, "starting zeroconf publishing"); - CZeroconf::GetInstance()->Start(); + CSettingString *screensaverMode = (CSettingString*)setting; + // we no longer ship the built-in slideshow screensaver, replace it if it's still in use + if (StringUtils::EqualsNoCase(screensaverMode->GetValue(), "screensaver.xbmc.builtin.slideshow")) + return screensaverMode->SetValue("screensaver.xbmc.builtin.dim"); } -#endif -} - -void CApplication::StopZeroconf() -{ -#ifdef HAS_ZEROCONF - if(CZeroconf::IsInstantiated()) + else if (settingId == "scrapers.musicvideosdefault") { - CLog::Log(LOGNOTICE, "stopping zeroconf publishing"); - CZeroconf::GetInstance()->Stop(); + CSettingAddon *musicvideoScraper = (CSettingAddon*)setting; + if (StringUtils::EqualsNoCase(musicvideoScraper->GetValue(), "metadata.musicvideos.last.fm")) + { + musicvideoScraper->Reset(); + return true; + } } -#endif -} - -void CApplication::StartPVRManager(bool bOpenPVRWindow /* = false */) -{ - if (g_guiSettings.GetBool("pvrmanager.enabled")) - g_PVRManager.Start(true, bOpenPVRWindow); -} - -void CApplication::StopPVRManager() -{ - CLog::Log(LOGINFO, "stopping PVRManager"); - if (g_PVRManager.IsPlaying()) - StopPlaying(); - g_PVRManager.Stop(); - g_EpgContainer.Stop(); -} - -void CApplication::StartServices() -{ -#if !defined(_WIN32) && defined(HAS_DVD_DRIVE) - // Start Thread for DVD Mediatype detection - CLog::Log(LOGNOTICE, "start dvd mediatype detection"); - m_DetectDVDType.Create(false, THREAD_MINSTACKSIZE); -#endif - CLog::Log(LOGNOTICE, "initializing playlistplayer"); - g_playlistPlayer.SetRepeat(PLAYLIST_MUSIC, CMediaSettings::Get().DoesMusicPlaylistRepeat() ? PLAYLIST::REPEAT_ALL : PLAYLIST::REPEAT_NONE); - g_playlistPlayer.SetShuffle(PLAYLIST_MUSIC, CMediaSettings::Get().IsMusicPlaylistShuffled()); - g_playlistPlayer.SetRepeat(PLAYLIST_VIDEO, CMediaSettings::Get().DoesVideoPlaylistRepeat() ? PLAYLIST::REPEAT_ALL : PLAYLIST::REPEAT_NONE); - g_playlistPlayer.SetShuffle(PLAYLIST_VIDEO, CMediaSettings::Get().IsVideoPlaylistShuffled()); - CLog::Log(LOGNOTICE, "DONE initializing playlistplayer"); + return false; } -void CApplication::StopServices() +bool CApplication::OnSettingsSaving() const { - m_network->NetworkMessage(CNetwork::SERVICES_DOWN, 0); - -#if !defined(_WIN32) && defined(HAS_DVD_DRIVE) - CLog::Log(LOGNOTICE, "stop dvd detect media"); - m_DetectDVDType.StopThread(); -#endif + // 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 + if (m_bStop) + return false; - g_peripherals.Clear(); + return true; } void CApplication::ReloadSkin() @@ -1950,7 +1665,7 @@ void CApplication::ReloadSkin() if (pWindow) iCtrlID = pWindow->GetFocusedControlID(); - g_application.LoadSkin(g_guiSettings.GetString("lookandfeel.skin")); + g_application.LoadSkin(CSettings::Get().GetString("lookandfeel.skin")); if (iCtrlID != -1) { @@ -1963,14 +1678,6 @@ 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::Load(const TiXmlNode *settings) { if (settings == NULL) @@ -2019,11 +1726,11 @@ bool CApplication::LoadSkin(const CStdString& skinID) void CApplication::LoadSkin(const SkinPtr& skin) { + string defaultSkin = ((const CSettingString*)CSettings::Get().GetSetting("lookandfeel.skin"))->GetDefault(); if (!skin) { - CLog::Log(LOGERROR, "failed to load requested skin, fallback to \"%s\" skin", DEFAULT_SKIN); - g_guiSettings.SetString("lookandfeel.skin", DEFAULT_SKIN); - LoadSkin(DEFAULT_SKIN); + CLog::Log(LOGERROR, "failed to load requested skin, fallback to \"%s\" skin", defaultSkin.c_str()); + CSettings::Get().SetString("lookandfeel.skin", defaultSkin); return ; } @@ -2032,11 +1739,11 @@ void CApplication::LoadSkin(const SkinPtr& skin) { // failed to find home.xml // fallback to default skin - if (strcmpi(skin->ID().c_str(), DEFAULT_SKIN) != 0) + if (strcmpi(skin->ID().c_str(), defaultSkin.c_str()) != 0) { - CLog::Log(LOGERROR, "home.xml doesn't exist in skin: %s, fallback to \"%s\" skin", skin->ID().c_str(), DEFAULT_SKIN); - g_guiSettings.SetString("lookandfeel.skin", DEFAULT_SKIN); - LoadSkin(DEFAULT_SKIN); + CLog::Log(LOGERROR, "home.xml doesn't exist in skin: %s, fallback to \"%s\" skin", skin->ID().c_str(), defaultSkin.c_str()); + CSettings::Get().SetString("lookandfeel.skin", defaultSkin); + LoadSkin(defaultSkin); CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(24102), g_localizeStrings.Get(24103)); return ; } @@ -2077,29 +1784,29 @@ void CApplication::LoadSkin(const SkinPtr& skin) CLog::Log(LOGINFO, " load fonts for skin..."); g_graphicsContext.SetMediaDir(skin->Path()); g_directoryCache.ClearSubPaths(skin->Path()); - if (g_langInfo.ForceUnicodeFont() && !g_fontManager.IsFontSetUnicode(g_guiSettings.GetString("lookandfeel.font"))) + if (g_langInfo.ForceUnicodeFont() && !g_fontManager.IsFontSetUnicode(CSettings::Get().GetString("lookandfeel.font"))) { CLog::Log(LOGINFO, " language needs a ttf font, loading first ttf font available"); CStdString strFontSet; if (g_fontManager.GetFirstFontSetUnicode(strFontSet)) { CLog::Log(LOGINFO, " new font is '%s'", strFontSet.c_str()); - g_guiSettings.SetString("lookandfeel.font", strFontSet); - g_settings.Save(); + CSettings::Get().SetString("lookandfeel.font", strFontSet); + CSettings::Get().Save(); } else - CLog::Log(LOGERROR, " no ttf font found, but needed for the language %s.", g_guiSettings.GetString("locale.language").c_str()); + CLog::Log(LOGERROR, " no ttf font found, but needed for the language %s.", CSettings::Get().GetString("locale.language").c_str()); } - g_colorManager.Load(g_guiSettings.GetString("lookandfeel.skincolors")); + g_colorManager.Load(CSettings::Get().GetString("lookandfeel.skincolors")); - g_fontManager.LoadFonts(g_guiSettings.GetString("lookandfeel.font")); + g_fontManager.LoadFonts(CSettings::Get().GetString("lookandfeel.font")); // load in the skin strings CStdString langPath; URIUtils::AddFileToFolder(skin->Path(), "language", langPath); URIUtils::AddSlashAtEnd(langPath); - g_localizeStrings.LoadSkinStrings(langPath, g_guiSettings.GetString("locale.language")); + g_localizeStrings.LoadSkinStrings(langPath, CSettings::Get().GetString("locale.language")); g_SkinInfo->LoadIncludes(); @@ -2360,7 +2067,7 @@ void CApplication::Render() MEASURE_FUNCTION; - int vsync_mode = g_guiSettings.GetInt("videoscreen.vsync"); + int vsync_mode = CSettings::Get().GetInt("videoscreen.vsync"); bool decrement = false; bool hasRendered = false; @@ -2584,7 +2291,7 @@ bool CApplication::OnKey(const CKey& key) if (useKeyboard) { action = CAction(0); // reset our action - if (g_guiSettings.GetBool("input.remoteaskeyboard")) + if (CSettings::Get().GetBool("input.remoteaskeyboard")) { // users remote is executing keyboard commands, so use the virtualkeyboard section of keymap.xml // and send those rather than actual keyboard presses. Only for navigation-type commands though @@ -2978,13 +2685,13 @@ bool CApplication::OnAction(const CAction &action) if (action.GetID() == ACTION_TOGGLE_DIGITAL_ANALOG) { // we are only allowed to SetInt to a value supported in GUISettings, so we keep trying until it sticks - int mode = g_guiSettings.GetInt("audiooutput.mode"); - for (int i = 0; i < AUDIO_COUNT; i++) + int mode = CSettings::Get().GetInt("audiooutput.mode"); + for (int i = 0; i < 3; i++) { - if (++mode == AUDIO_COUNT) + if (++mode == 3) mode = 0; - g_guiSettings.SetInt("audiooutput.mode", mode); - if (g_guiSettings.GetInt("audiooutput.mode") == mode) + CSettings::Get().SetInt("audiooutput.mode", mode); + if (CSettings::Get().GetInt("audiooutput.mode") == mode) break; } @@ -3586,26 +3293,8 @@ bool CApplication::Cleanup() #endif DllLoaderContainer::Clear(); g_playlistPlayer.Clear(); - g_settings.Clear(); - g_guiSettings.Clear(); + CSettings::Get().Uninitialize(); g_advancedSettings.Clear(); - - g_settings.UnregisterSubSettings(this); - g_settings.UnregisterSubSettings(&CDisplaySettings::Get()); - g_settings.UnregisterSubSettings(&CMediaSettings::Get()); - g_settings.UnregisterSubSettings(&CSkinSettings::Get()); - g_settings.UnregisterSubSettings(&g_sysinfo); - 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(&CProfilesManager::Get()); - g_settings.UnregisterSettingsHandler(this); #ifdef _LINUX CXHandle::DumpObjectTracker(); @@ -3659,7 +3348,7 @@ void CApplication::Stop(int exitCode) if (CFile::Exists(CProfilesManager::Get().GetSettingsFile())) { CLog::Log(LOGNOTICE, "Saving settings"); - g_settings.Save(); + CSettings::Get().Save(); } else CLog::Log(LOGNOTICE, "Not saving settings (settings.xml is not present)"); @@ -3682,19 +3371,6 @@ void CApplication::Stop(int exitCode) StopServices(); //Sleep(5000); -#ifdef HAS_WEB_SERVER - CWebServer::UnregisterRequestHandler(&m_httpImageHandler); - CWebServer::UnregisterRequestHandler(&m_httpVfsHandler); -#ifdef HAS_JSONRPC - CWebServer::UnregisterRequestHandler(&m_httpJsonRpcHandler); - CJSONRPC::Cleanup(); -#endif -#ifdef HAS_WEB_INTERFACE - CWebServer::UnregisterRequestHandler(&m_httpWebinterfaceAddonsHandler); - CWebServer::UnregisterRequestHandler(&m_httpWebinterfaceHandler); -#endif -#endif - if (m_pPlayer) { CLog::Log(LOGNOTICE, "stop player"); @@ -4698,7 +4374,7 @@ bool CApplication::WakeUpScreenSaver(bool bPowerOffKeyPressed /* = false */) { if (m_iScreenSaveLock == 0) if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && - (CProfilesManager::Get().UsingLoginScreen() || g_guiSettings.GetBool("masterlock.startuplock")) && + (CProfilesManager::Get().UsingLoginScreen() || CSettings::Get().GetBool("masterlock.startuplock")) && CProfilesManager::Get().GetCurrentProfile().getLockMode() != LOCK_MODE_EVERYONE && m_screenSaver->ID() != "screensaver.xbmc.builtin.dim" && m_screenSaver->ID() != "screensaver.xbmc.builtin.black" && !m_screenSaver->ID().empty() && m_screenSaver->ID() != "visualization") { @@ -4749,10 +4425,10 @@ void CApplication::CheckScreenSaverAndDPMS() bool maybeScreensaver = !m_dpmsIsActive && !m_bScreenSave - && !g_guiSettings.GetString("screensaver.mode").IsEmpty(); + && !CSettings::Get().GetString("screensaver.mode").empty(); bool maybeDPMS = !m_dpmsIsActive && m_dpms->IsSupported() - && g_guiSettings.GetInt("powermanagement.displaysoff") > 0; + && CSettings::Get().GetInt("powermanagement.displaysoff") > 0; // Has the screen saver window become active? if (maybeScreensaver && g_windowManager.IsWindowActive(WINDOW_SCREENSAVER)) @@ -4774,7 +4450,7 @@ void CApplication::CheckScreenSaverAndDPMS() if ((IsPlayingVideo() && !m_pPlayer->IsPaused()) // * Are we playing some music in fullscreen vis? || (IsPlayingAudio() && g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION - && !g_guiSettings.GetString("musicplayer.visualisation").IsEmpty())) + && !CSettings::Get().GetString("musicplayer.visualisation").empty())) { ResetScreenSaverTimer(); return; @@ -4784,13 +4460,13 @@ void CApplication::CheckScreenSaverAndDPMS() // DPMS has priority (it makes the screensaver not needed) if (maybeDPMS - && elapsed > g_guiSettings.GetInt("powermanagement.displaysoff") * 60) + && elapsed > CSettings::Get().GetInt("powermanagement.displaysoff") * 60) { ToggleDPMS(false); WakeUpScreenSaver(); } else if (maybeScreensaver - && elapsed > g_guiSettings.GetInt("screensaver.time") * 60) + && elapsed > CSettings::Get().GetInt("screensaver.time") * 60) { ActivateScreenSaver(); } @@ -4805,7 +4481,7 @@ void CApplication::ActivateScreenSaver(bool forceType /*= false */) // Get Screensaver Mode m_screenSaver.reset(); - if (!CAddonMgr::Get().GetAddon(g_guiSettings.GetString("screensaver.mode"), m_screenSaver)) + if (!CAddonMgr::Get().GetAddon(CSettings::Get().GetString("screensaver.mode"), m_screenSaver)) m_screenSaver.reset(new CScreenSaver("")); CAnnouncementManager::Announce(GUI, "xbmc", "OnScreensaverActivated"); @@ -4815,13 +4491,13 @@ void CApplication::ActivateScreenSaver(bool forceType /*= false */) if (!forceType) { // set to Dim in the case of a dialog on screen or playing video - if (g_windowManager.HasModalDialog() || (IsPlayingVideo() && g_guiSettings.GetBool("screensaver.usedimonpause")) || g_PVRManager.IsRunningChannelScan()) + if (g_windowManager.HasModalDialog() || (IsPlayingVideo() && CSettings::Get().GetBool("screensaver.usedimonpause")) || g_PVRManager.IsRunningChannelScan()) { if (!CAddonMgr::Get().GetAddon("screensaver.xbmc.builtin.dim", m_screenSaver)) m_screenSaver.reset(new CScreenSaver("")); } // Check if we are Playing Audio and Vis instead Screensaver! - else if (IsPlayingAudio() && g_guiSettings.GetBool("screensaver.usemusicvisinstead") && !g_guiSettings.GetString("musicplayer.visualisation").IsEmpty()) + else if (IsPlayingAudio() && CSettings::Get().GetBool("screensaver.usemusicvisinstead") && !CSettings::Get().GetString("musicplayer.visualisation").empty()) { // activate the visualisation m_screenSaver.reset(new CScreenSaver("visualization")); g_windowManager.ActivateWindow(WINDOW_VISUALISATION); @@ -4862,7 +4538,7 @@ void CApplication::CheckShutdown() if (g_windowManager.IsWindowActive(WINDOW_DIALOG_PROGRESS)) // progress dialog is onscreen resetTimer = true; - if (g_guiSettings.GetBool("pvrmanager.enabled") && !g_PVRManager.IsIdle()) + if (CSettings::Get().GetBool("pvrmanager.enabled") && !g_PVRManager.IsIdle()) resetTimer = true; if (resetTimer) @@ -4871,7 +4547,7 @@ void CApplication::CheckShutdown() return; } - if ( m_shutdownTimer.GetElapsedSeconds() > g_guiSettings.GetInt("powermanagement.shutdowntime") * 60 ) + if ( m_shutdownTimer.GetElapsedSeconds() > CSettings::Get().GetInt("powermanagement.shutdowntime") * 60 ) { // Since it is a sleep instead of a shutdown, let's set everything to reset when we wake up. m_shutdownTimer.Stop(); @@ -4952,7 +4628,7 @@ bool CApplication::OnMessage(CGUIMessage& message) { // Start our cdg parser as appropriate #ifdef HAS_KARAOKE - if (m_pKaraokeMgr && g_guiSettings.GetBool("karaoke.enabled") && !m_itemCurrentFile->IsInternetStream()) + if (m_pKaraokeMgr && CSettings::Get().GetBool("karaoke.enabled") && !m_itemCurrentFile->IsInternetStream()) { m_pKaraokeMgr->Stop(); if (m_itemCurrentFile->IsMusicDb()) @@ -5093,7 +4769,7 @@ bool CApplication::OnMessage(CGUIMessage& message) if (!IsPlayingAudio() && g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_NONE && g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION) { - g_settings.Save(); // save vis settings + CSettings::Get().Save(); // save vis settings WakeUpScreenSaverAndDPMS(); g_windowManager.PreviousWindow(); } @@ -5102,7 +4778,7 @@ bool CApplication::OnMessage(CGUIMessage& message) if (!IsPlayingAudio() && (m_itemCurrentFile->IsCDDA() || m_itemCurrentFile->IsOnDVD()) && !g_mediaManager.IsDiscInDrive() && g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION) { // yes, disable vis - g_settings.Save(); // save vis settings + CSettings::Get().Save(); // save vis settings WakeUpScreenSaverAndDPMS(); g_windowManager.PreviousWindow(); } @@ -5238,9 +4914,9 @@ void CApplication::ProcessSlow() // Check if we need to shutdown (if enabled). #if defined(TARGET_DARWIN) - if (g_guiSettings.GetInt("powermanagement.shutdowntime") && g_advancedSettings.m_fullScreen) + if (CSettings::Get().GetInt("powermanagement.shutdowntime") && g_advancedSettings.m_fullScreen) #else - if (g_guiSettings.GetInt("powermanagement.shutdowntime")) + if (CSettings::Get().GetInt("powermanagement.shutdowntime")) #endif { CheckShutdown(); @@ -5761,13 +5437,13 @@ PLAYERCOREID CApplication::GetCurrentPlayer() void CApplication::UpdateLibraries() { - if (g_guiSettings.GetBool("videolibrary.updateonstartup")) + if (CSettings::Get().GetBool("videolibrary.updateonstartup")) { CLog::Log(LOGNOTICE, "%s - Starting video library startup scan", __FUNCTION__); StartVideoScan(""); } - if (g_guiSettings.GetBool("musiclibrary.updateonstartup")) + if (CSettings::Get().GetBool("musiclibrary.updateonstartup")) { CLog::Log(LOGNOTICE, "%s - Starting music library startup scan", __FUNCTION__); StartMusicScan(""); @@ -5821,9 +5497,9 @@ void CApplication::StartMusicScan(const CStdString &strDirectory, int flags) if (!flags) { // setup default flags - if (g_guiSettings.GetBool("musiclibrary.downloadinfo")) + if (CSettings::Get().GetBool("musiclibrary.downloadinfo")) flags |= CMusicInfoScanner::SCAN_ONLINE; - if (g_guiSettings.GetBool("musiclibrary.backgroundupdate")) + if (CSettings::Get().GetBool("musiclibrary.backgroundupdate")) flags |= CMusicInfoScanner::SCAN_BACKGROUND; } @@ -5994,7 +5670,7 @@ CPerformanceStats &CApplication::GetPerformanceStats() bool CApplication::SetLanguage(const CStdString &strLanguage) { - CStdString strPreviousLanguage = g_guiSettings.GetString("locale.language"); + CStdString strPreviousLanguage = CSettings::Get().GetString("locale.language"); CStdString strNewLanguage = strLanguage; if (strNewLanguage != strPreviousLanguage) { @@ -6012,7 +5688,7 @@ bool CApplication::SetLanguage(const CStdString &strLanguage) else CLog::Log(LOGERROR, "No ttf font found but needed: %s", strFontSet.c_str()); } - g_guiSettings.SetString("locale.language", strNewLanguage); + CSettings::Get().SetString("locale.language", strNewLanguage); g_charsetConverter.reset(); diff --git a/xbmc/Application.h b/xbmc/Application.h index 4e02f67a60a86..c60195dbdf9a0 100644 --- a/xbmc/Application.h +++ b/xbmc/Application.h @@ -50,6 +50,7 @@ class CPlayerController; #include "cores/playercorefactory/PlayerCoreFactory.h" #include "PlayListPlayer.h" #include "settings/ISettingsHandler.h" +#include "settings/ISettingCallback.h" #include "settings/ISubSettings.h" #if !defined(_WIN32) && defined(HAS_DVD_DRIVE) #include "storage/DetectDVDType.h" @@ -70,21 +71,6 @@ class CInertialScrollingHandler; class DPMSSupport; class CSplash; class CBookmark; -class CWebServer; -class IPlayer; -#ifdef HAS_WEB_SERVER -class CWebServer; -class CHTTPImageHandler; -class CHTTPVfsHandler; -#ifdef HAS_JSONRPC -class CHTTPJsonRpcHandler; -#endif -#ifdef HAS_WEB_INTERFACE -class CHTTPWebinterfaceHandler; -class CHTTPWebinterfaceAddonsHandler; -#endif -#endif - class CNetwork; namespace VIDEO @@ -102,6 +88,16 @@ namespace MUSIC_INFO #define VOLUME_DYNAMIC_RANGE 90.0f // 60dB #define VOLUME_CONTROL_STEPS 90 // 90 steps +// replay gain settings struct for quick access by the player multiple +// times per second (saves doing settings lookup) +struct ReplayGainSettings +{ + int iPreAmp; + int iNoGainPreAmp; + int iType; + bool bAvoidClipping; +}; + class CBackgroundPlayer : public CThread { public: @@ -114,7 +110,7 @@ class CBackgroundPlayer : public CThread }; class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMsgTargetCallback, - public ISettingsHandler, public ISubSettings + public ISettingCallback, public ISettingsHandler, public ISubSettings { public: @@ -147,27 +143,8 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs bool StartServer(enum ESERVERS eServer, bool bStart, bool bWait = false); - bool StartWebServer(); - void StopWebServer(); - bool StartAirplayServer(); - void StopAirplayServer(bool bWait); - bool StartJSONRPCServer(); - void StopJSONRPCServer(bool bWait); - void StartUPnP(); - void StopUPnP(bool bWait); - void StartUPnPClient(); - void StopUPnPClient(); - void StartUPnPRenderer(); - void StopUPnPRenderer(); - void StartUPnPServer(); - void StopUPnPServer(); void StartPVRManager(bool bOpenPVRWindow = false); void StopPVRManager(); - bool StartEventServer(); - bool StopEventServer(bool bWait, bool promptuser); - void RefreshEventServer(); - void StartZeroconf(); - void StopZeroconf(); bool IsCurrentThread() const; void Stop(int exitCode); void RestartApp(); @@ -291,19 +268,6 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs IPlayer* m_pPlayer; -#ifdef HAS_WEB_SERVER - CWebServer& m_WebServer; - CHTTPImageHandler& m_httpImageHandler; - CHTTPVfsHandler& m_httpVfsHandler; -#ifdef HAS_JSONRPC - CHTTPJsonRpcHandler& m_httpJsonRpcHandler; -#endif -#ifdef HAS_WEB_INTERFACE - CHTTPWebinterfaceHandler& m_httpWebinterfaceHandler; - CHTTPWebinterfaceAddonsHandler& m_httpWebinterfaceAddonsHandler; -#endif -#endif - inline bool IsInScreenSaver() { return m_bScreenSave; }; int m_iScreenSaveLock; // spiff: are we checking for a lock? if so, ignore the screensaver state, if -1 we have failed to input locks @@ -379,12 +343,18 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs bool GetRenderGUI() const { return m_renderGUI; }; bool SetLanguage(const CStdString &strLanguage); + + ReplayGainSettings& GetReplayGainSettings() { return m_replayGainSettings; } protected: virtual bool OnSettingsSaving() const; virtual bool Load(const TiXmlNode *settings); virtual bool Save(TiXmlNode *settings) const; + virtual void OnSettingChanged(const CSetting *setting); + virtual void OnSettingAction(const CSetting *setting); + virtual bool OnSettingUpdate(CSetting* &setting, const char *oldSettingId, const TiXmlNode *oldSettingNode); + bool LoadSkin(const CStdString& skinID); void LoadSkin(const boost::shared_ptr& skin); @@ -494,6 +464,7 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs std::map > m_lastAxisMap; #endif + ReplayGainSettings m_replayGainSettings; }; XBMC_GLOBAL_REF(CApplication,g_application); diff --git a/xbmc/ApplicationMessenger.cpp b/xbmc/ApplicationMessenger.cpp index 9be09ab1c1444..5ab05fde956c0 100644 --- a/xbmc/ApplicationMessenger.cpp +++ b/xbmc/ApplicationMessenger.cpp @@ -22,6 +22,7 @@ #include "ApplicationMessenger.h" #include "Application.h" +#include "LangInfo.h" #include "PlayListPlayer.h" #include "Util.h" #ifdef HAS_PYTHON @@ -34,11 +35,11 @@ #include "utils/URIUtils.h" #include "utils/Variant.h" #include "guilib/GUIWindowManager.h" -#include "guilib/Key.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "FileItem.h" #include "guilib/GUIDialog.h" +#include "guilib/Key.h" #include "GUIInfoManager.h" #include "utils/Splash.h" #include "cores/IPlayer.h" @@ -227,7 +228,7 @@ void CApplicationMessenger::ProcessMessage(ThreadMessage *pMsg) { case TMSG_SHUTDOWN: { - switch (g_guiSettings.GetInt("powermanagement.shutdownstate")) + switch (CSettings::Get().GetInt("powermanagement.shutdownstate")) { case POWERSTATE_SHUTDOWN: Powerdown(); @@ -456,7 +457,7 @@ void CApplicationMessenger::ProcessMessage(ThreadMessage *pMsg) { if(items.Size() == 0) { - g_guiSettings.SetString("screensaver.mode", "screensaver.xbmc.builtin.dim"); + CSettings::Get().SetString("screensaver.mode", "screensaver.xbmc.builtin.dim"); g_application.ActivateScreenSaver(); } else diff --git a/xbmc/AutoSwitch.cpp b/xbmc/AutoSwitch.cpp index 13b9541ed550b..6d51d7f317f07 100644 --- a/xbmc/AutoSwitch.cpp +++ b/xbmc/AutoSwitch.cpp @@ -19,10 +19,10 @@ */ #include "AutoSwitch.h" -#include "settings/GUISettings.h" -#include "guilib/GUIWindowManager.h" #include "FileItem.h" +#include "guilib/GUIWindowManager.h" #include "guilib/WindowIDs.h" +#include "settings/Settings.h" #include "view/ViewState.h" #define METHOD_BYFOLDERS 0 @@ -44,7 +44,7 @@ int CAutoSwitch::GetView(const CFileItemList &vecItems) int iSortMethod = -1; int iPercent = 0; int iCurrentWindow = g_windowManager.GetActiveWindow(); - bool bHideParentFolderItems = !g_guiSettings.GetBool("filelists.showparentdiritems"); + bool bHideParentFolderItems = !CSettings::Get().GetBool("filelists.showparentdiritems"); switch (iCurrentWindow) { diff --git a/xbmc/Autorun.cpp b/xbmc/Autorun.cpp index 47f5dbc7e2fc2..9411b7e04fbd2 100644 --- a/xbmc/Autorun.cpp +++ b/xbmc/Autorun.cpp @@ -32,9 +32,10 @@ #include "filesystem/DirectoryFactory.h" #include "filesystem/File.h" #include "profiles/ProfilesManager.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "playlists/PlayList.h" #include "guilib/GUIWindowManager.h" +#include "guilib/LocalizeStrings.h" #include "storage/MediaManager.h" #include "video/VideoDatabase.h" #include "dialogs/GUIDialogYesNo.h" @@ -70,7 +71,7 @@ void CAutorun::ExecuteAutorun(const CStdString& path, bool bypassSettings, bool g_application.ResetScreenSaver(); g_application.WakeUpScreenSaverAndDPMS(); // turn off the screensaver if it's active #ifdef HAS_CDDA_RIPPER - if (g_guiSettings.GetInt("audiocds.autoaction") == AUTOCD_RIP && + if (CSettings::Get().GetInt("audiocds.autoaction") == AUTOCD_RIP && pInfo->IsAudio(1) && !CProfilesManager::Get().GetCurrentProfile().musicLocked()) { CCDDARipper::GetInstance().RipCD(); @@ -82,7 +83,7 @@ void CAutorun::ExecuteAutorun(const CStdString& path, bool bypassSettings, bool bool CAutorun::PlayDisc(const CStdString& path, bool bypassSettings, bool startFromBeginning) { - if ( !bypassSettings && !g_guiSettings.GetInt("audiocds.autoaction") == AUTOCD_PLAY && !g_guiSettings.GetBool("dvds.autorun")) + if ( !bypassSettings && !CSettings::Get().GetInt("audiocds.autoaction") == AUTOCD_PLAY && !CSettings::Get().GetBool("dvds.autorun")) return false; int nSize = g_playlistPlayer.GetPlaylist( PLAYLIST_MUSIC ).size(); @@ -169,7 +170,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded // Check if the current foldername indicates a DVD structure (name is "VIDEO_TS") if (name.Equals("VIDEO_TS") && bAllowVideo - && (bypassSettings || g_guiSettings.GetBool("dvds.autorun"))) + && (bypassSettings || CSettings::Get().GetBool("dvds.autorun"))) { CStdString path = URIUtils::AddFileToFolder(pItem->GetPath(), "VIDEO_TS.IFO"); if(!CFile::Exists(path)) @@ -190,7 +191,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded // A BR should also include an "AACS" folder for encryption, Sony-BRs can also include update folders for PS3 (PS3_UPDATE / PS3_VPRM). // ToDo: for the time beeing, the DVD autorun settings are used to determine if the BR should be started automatically. if (name.Equals("BDMV") && bAllowVideo - && (bypassSettings || g_guiSettings.GetBool("dvds.autorun"))) + && (bypassSettings || CSettings::Get().GetBool("dvds.autorun"))) { CFileItem item(URIUtils::AddFileToFolder(pItem->GetPath(), "index.bdmv"), false); item.SetLabel(g_mediaManager.GetDiskLabel(strDrive)); @@ -228,7 +229,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded // Standard Content HD DVD (few discs?) if (name.Equals("HVDVD_TS") && bAllowVideo - && (bypassSettings || g_guiSettings.GetBool("dvds.autorun"))) + && (bypassSettings || CSettings::Get().GetBool("dvds.autorun"))) { if (hddvdname == "") { @@ -322,7 +323,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded // If a file format was extracted we are sure this is a VCD. Autoplay if settings indicate we should. if (!strExt.IsEmpty() && bAllowVideo - && (bypassSettings || g_guiSettings.GetBool("dvds.autorun"))) + && (bypassSettings || CSettings::Get().GetBool("dvds.autorun"))) { CFileItemList items; CDirectory::GetDirectory(pItem->GetPath(), items, strExt); @@ -353,12 +354,12 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded } // check video first - if (!nAddedToPlaylist && !bPlaying && (bypassSettings || g_guiSettings.GetBool("dvds.autorun"))) + if (!nAddedToPlaylist && !bPlaying && (bypassSettings || CSettings::Get().GetBool("dvds.autorun"))) { // stack video files CFileItemList tempItems; tempItems.Append(vecItems); - if (g_guiSettings.GetBool("myvideos.stackvideos")) + if (CSettings::Get().GetBool("myvideos.stackvideos")) tempItems.Stack(); CFileItemList itemlist; @@ -398,7 +399,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded } } // then music - if (!bPlaying && (bypassSettings || g_guiSettings.GetInt("audiocds.autoaction") == AUTOCD_PLAY) && bAllowMusic) + if (!bPlaying && (bypassSettings || CSettings::Get().GetInt("audiocds.autoaction") == AUTOCD_PLAY) && bAllowMusic) { for (int i = 0; i < vecItems.Size(); i++) { @@ -503,4 +504,25 @@ bool CAutorun::CanResumePlayDVD(const CStdString& path) return false; } +void CAutorun::SettingOptionAudioCdActionsFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t) +{ + list.push_back(make_pair(g_localizeStrings.Get(16018), AUTOCD_NONE)); + list.push_back(make_pair(g_localizeStrings.Get(14098), AUTOCD_PLAY)); +#ifdef HAS_CDDA_RIPPER + list.push_back(make_pair(g_localizeStrings.Get(14096), AUTOCD_RIP)); +#endif +} + +void CAutorun::SettingOptionAudioCdEncodersFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t) +{ +#ifdef HAVE_LIBMP3LAME + list.push_back(make_pair(g_localizeStrings.Get(34000), CDDARIP_ENCODER_LAME)); +#endif +#ifdef HAVE_LIBVORBISENC + list.push_back(make_pair(g_localizeStrings.Get(34001), CDDARIP_ENCODER_VORBIS)); +#endif + list.push_back(make_pair(g_localizeStrings.Get(34002), CDDARIP_ENCODER_WAV)); + list.push_back(make_pair(g_localizeStrings.Get(34005), CDDARIP_ENCODER_FLAC)); +} + #endif diff --git a/xbmc/Autorun.h b/xbmc/Autorun.h index e078c5ae72a8e..1faed11246445 100644 --- a/xbmc/Autorun.h +++ b/xbmc/Autorun.h @@ -39,6 +39,15 @@ namespace XFILE class IDirectory; } +class CSetting; + +enum AutoCDAction +{ + AUTOCD_NONE = 0, + AUTOCD_PLAY, + AUTOCD_RIP +}; + namespace MEDIA_DETECT { class CAutorun @@ -54,6 +63,10 @@ class CAutorun void Disable(); void HandleAutorun(); static void ExecuteAutorun(const CStdString& path = "", bool bypassSettings = false, bool ignoreplaying = false, bool startFromBeginning = false); + + static void SettingOptionAudioCdActionsFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t); + static void SettingOptionAudioCdEncodersFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t); + protected: static bool RunDisc(XFILE::IDirectory* pDir, const CStdString& strDrive, int& nAddedToPlaylist, bool bRoot, bool bypassSettings, bool startFromBeginning); bool m_bEnable; diff --git a/xbmc/FileItem.cpp b/xbmc/FileItem.cpp index d63bfa93c930d..83c765a7c0f4d 100644 --- a/xbmc/FileItem.cpp +++ b/xbmc/FileItem.cpp @@ -49,8 +49,8 @@ #include "music/Album.h" #include "music/Song.h" #include "URL.h" -#include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" +#include "settings/Settings.h" #include "utils/RegExp.h" #include "utils/log.h" #include "utils/Variant.h" @@ -167,7 +167,7 @@ CFileItem::CFileItem(const CPVRChannel& channel) *GetPVRChannelInfoTag() = channel; SetLabel(channel.ChannelName()); m_strLabel2 = bHasEpgNow ? epgNow.Title() : - g_guiSettings.GetBool("epg.hidenoinfoavailable") ? + CSettings::Get().GetBool("epg.hidenoinfoavailable") ? StringUtils::EmptyString : g_localizeStrings.Get(19055); // no information available @@ -2529,7 +2529,7 @@ void CFileItemList::StackFiles() // item->m_bIsFolder = true; // don't treat stacked files as folders // the label may be in a different char set from the filename (eg over smb // the label is converted from utf8, but the filename is not) - if (!g_guiSettings.GetBool("filelists.showextensions")) + if (!CSettings::Get().GetBool("filelists.showextensions")) URIUtils::RemoveExtension(stackName); item1->SetLabel(stackName); @@ -2654,7 +2654,7 @@ CStdString CFileItem::GetUserMusicThumb(bool alwaysCheckRemote /* = false */, bo } // if a folder, check for folder.jpg - if (m_bIsFolder && !IsFileFolder() && (!IsRemote() || alwaysCheckRemote || g_guiSettings.GetBool("musicfiles.findremotethumbs"))) + if (m_bIsFolder && !IsFileFolder() && (!IsRemote() || alwaysCheckRemote || CSettings::Get().GetBool("musicfiles.findremotethumbs"))) { CStdStringArray thumbs; StringUtils::SplitString(g_advancedSettings.m_musicThumbs, "|", thumbs); diff --git a/xbmc/GUIInfoManager.cpp b/xbmc/GUIInfoManager.cpp index f5320ddbdcd32..bb996e2100713 100644 --- a/xbmc/GUIInfoManager.cpp +++ b/xbmc/GUIInfoManager.cpp @@ -81,6 +81,7 @@ #include "video/VideoDatabase.h" #include "cores/IPlayer.h" #include "cores/AudioEngine/Utils/AEUtil.h" +#include "cores/VideoRenderers/BaseRenderer.h" #define SYSHEATUPDATEINTERVAL 60000 @@ -1339,7 +1340,7 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fa URIUtils::RemoveExtension(strLabel); break; case WEATHER_PLUGIN: - strLabel = g_guiSettings.GetString("weather.addon"); + strLabel = CSettings::Get().GetString("weather.addon"); break; case SYSTEM_DATE: strLabel = GetDate(); @@ -1412,7 +1413,7 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fa CEpgInfoTag tag; return m_currentFile->GetPVRChannelInfoTag()->GetEPGNow(tag) ? tag.Title() : - g_guiSettings.GetBool("epg.hidenoinfoavailable") ? + CSettings::Get().GetBool("epg.hidenoinfoavailable") ? StringUtils::EmptyString : g_localizeStrings.Get(19055); // no information available } @@ -1716,7 +1717,7 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fa return g_localizeStrings.Get(g_windowManager.GetFocusedWindow()); break; case SYSTEM_STARTUP_WINDOW: - strLabel.Format("%i", g_guiSettings.GetInt("lookandfeel.startupwindow")); + strLabel.Format("%i", CSettings::Get().GetInt("lookandfeel.startupwindow")); break; case SYSTEM_CURRENT_CONTROL: { @@ -1760,7 +1761,7 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fa } break; case SYSTEM_LANGUAGE: - strLabel = g_guiSettings.GetString("locale.language"); + strLabel = CSettings::Get().GetString("locale.language"); break; case SYSTEM_TEMPERATURE_UNITS: strLabel = g_langInfo.GetTempUnitString(); @@ -1774,7 +1775,7 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fa break; case SYSTEM_FRIENDLY_NAME: { - CStdString friendlyName = g_guiSettings.GetString("services.devicename"); + CStdString friendlyName = CSettings::Get().GetString("services.devicename"); if (friendlyName.Equals("XBMC")) strLabel.Format("%s (%s)", friendlyName.c_str(), g_application.getNetwork().GetHostName().c_str()); else @@ -1783,10 +1784,10 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fa break; case SKIN_THEME: - strLabel = g_guiSettings.GetString("lookandfeel.skintheme"); + strLabel = CSettings::Get().GetString("lookandfeel.skintheme"); break; case SKIN_COLOUR_THEME: - strLabel = g_guiSettings.GetString("lookandfeel.skincolors"); + strLabel = CSettings::Get().GetString("lookandfeel.skincolors"); break; case SKIN_ASPECT_RATIO: if (g_SkinInfo) @@ -1865,7 +1866,7 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fa case VISUALISATION_NAME: { AddonPtr addon; - strLabel = g_guiSettings.GetString("musicplayer.visualisation"); + strLabel = CSettings::Get().GetString("musicplayer.visualisation"); if (CAddonMgr::Get().GetAddon(strLabel,addon) && addon) strLabel = addon->Name(); } @@ -2191,7 +2192,7 @@ bool CGUIInfoManager::GetBool(int condition1, int contextWindow, const CGUIListI else if (condition == SYSTEM_ISINHIBIT) bReturn = g_application.IsIdleShutdownInhibited(); else if (condition == SYSTEM_HAS_SHUTDOWN) - bReturn = (g_guiSettings.GetInt("powermanagement.shutdowntime") > 0); + bReturn = (CSettings::Get().GetInt("powermanagement.shutdowntime") > 0); else if (condition == SYSTEM_LOGGEDON) bReturn = !(g_windowManager.GetActiveWindow() == WINDOW_LOGIN_SCREEN); else if (condition == SYSTEM_SHOW_EXIT_BUTTON) @@ -2433,7 +2434,7 @@ bool CGUIInfoManager::GetBool(int condition1, int contextWindow, const CGUIListI } break; case VIDEOPLAYER_USING_OVERLAYS: - bReturn = (g_guiSettings.GetInt("videoplayer.rendermethod") == RENDER_OVERLAYS); + bReturn = (CSettings::Get().GetInt("videoplayer.rendermethod") == RENDER_OVERLAYS); break; case VIDEOPLAYER_ISFULLSCREEN: bReturn = g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO; @@ -2475,7 +2476,7 @@ bool CGUIInfoManager::GetBool(int condition1, int contextWindow, const CGUIListI } break; case VISUALISATION_ENABLED: - bReturn = !g_guiSettings.GetString("musicplayer.visualisation").IsEmpty(); + bReturn = !CSettings::Get().GetString("musicplayer.visualisation").empty(); break; case VIDEOPLAYER_HAS_EPG: if (m_currentFile->HasPVRChannelInfoTag()) @@ -2547,7 +2548,7 @@ bool CGUIInfoManager::GetMultiInfoBool(const GUIInfo &info, int contextWindow, c break; case SKIN_HAS_THEME: { - CStdString theme = g_guiSettings.GetString("lookandfeel.skintheme"); + CStdString theme = CSettings::Get().GetString("lookandfeel.skintheme"); theme.ToLower(); URIUtils::RemoveExtension(theme); bReturn = theme.Equals(m_stringParameters[info.GetData1()]); @@ -2717,7 +2718,7 @@ bool CGUIInfoManager::GetMultiInfoBool(const GUIInfo &info, int contextWindow, c bReturn = g_alarmClock.HasAlarm(m_stringParameters[info.GetData1()]); break; case SYSTEM_GET_BOOL: - bReturn = g_guiSettings.GetBool(m_stringParameters[info.GetData1()]); + bReturn = CSettings::Get().GetBool(m_stringParameters[info.GetData1()]); break; case SYSTEM_HAS_CORE_ID: bReturn = g_cpuInfo.HasCoreId(info.GetData1()); @@ -3583,7 +3584,7 @@ CStdString CGUIInfoManager::GetVideoLabel(int item) case VIDEOPLAYER_ORIGINALTITLE: return tag->GetEPGNow(epgTag) ? epgTag.Title() : - g_guiSettings.GetBool("epg.hidenoinfoavailable") ? + CSettings::Get().GetBool("epg.hidenoinfoavailable") ? StringUtils::EmptyString : g_localizeStrings.Get(19055); // no information available case VIDEOPLAYER_GENRE: @@ -3601,7 +3602,7 @@ CStdString CGUIInfoManager::GetVideoLabel(int item) case VIDEOPLAYER_NEXT_TITLE: return tag->GetEPGNext(epgTag) ? epgTag.Title() : - g_guiSettings.GetBool("epg.hidenoinfoavailable") ? + CSettings::Get().GetBool("epg.hidenoinfoavailable") ? StringUtils::EmptyString : g_localizeStrings.Get(19055); // no information available case VIDEOPLAYER_NEXT_GENRE: @@ -4214,7 +4215,7 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, CStdSt CEpgInfoTag epgTag; return item->GetPVRChannelInfoTag()->GetEPGNow(epgTag) ? epgTag.Title() : - g_guiSettings.GetBool("epg.hidenoinfoavailable") ? + CSettings::Get().GetBool("epg.hidenoinfoavailable") ? StringUtils::EmptyString : g_localizeStrings.Get(19055); // no information available } @@ -4450,7 +4451,7 @@ CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, CStdSt if (item->HasVideoInfoTag()) { if (!(!item->GetVideoInfoTag()->m_strShowTitle.IsEmpty() && item->GetVideoInfoTag()->m_iSeason == -1)) // dont apply to tvshows - if (item->GetVideoInfoTag()->m_playCount == 0 && !g_guiSettings.GetBool("videolibrary.showunwatchedplots")) + if (item->GetVideoInfoTag()->m_playCount == 0 && !CSettings::Get().GetBool("videolibrary.showunwatchedplots")) return g_localizeStrings.Get(20370); return item->GetVideoInfoTag()->m_strPlot; diff --git a/xbmc/GUILargeTextureManager.cpp b/xbmc/GUILargeTextureManager.cpp index dca794f524351..bc66088c5bc76 100644 --- a/xbmc/GUILargeTextureManager.cpp +++ b/xbmc/GUILargeTextureManager.cpp @@ -20,7 +20,7 @@ #include "threads/SystemClock.h" #include "GUILargeTextureManager.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "guilib/Texture.h" #include "threads/SingleLock.h" #include "utils/TimeUtils.h" @@ -61,7 +61,7 @@ bool CImageLoader::DoWork() { // direct route - load the image unsigned int start = XbmcThreads::SystemClockMillis(); - m_texture = CBaseTexture::LoadFromFile(loadPath, g_graphicsContext.GetWidth(), g_graphicsContext.GetHeight(), g_guiSettings.GetBool("pictures.useexifrotation")); + m_texture = CBaseTexture::LoadFromFile(loadPath, g_graphicsContext.GetWidth(), g_graphicsContext.GetHeight(), CSettings::Get().GetBool("pictures.useexifrotation")); if (!m_texture) return false; if (XbmcThreads::SystemClockMillis() - start > 100) diff --git a/xbmc/GUIPassword.cpp b/xbmc/GUIPassword.cpp index 161edffcd9ae5..778f362b79143 100644 --- a/xbmc/GUIPassword.cpp +++ b/xbmc/GUIPassword.cpp @@ -29,8 +29,8 @@ #include "profiles/dialogs/GUIDialogLockSettings.h" #include "profiles/dialogs/GUIDialogProfileSettings.h" #include "Util.h" -#include "settings/GUISettings.h" #include "settings/MediaSourceSettings.h" +#include "settings/Settings.h" #include "guilib/GUIWindowManager.h" #include "FileItem.h" #include "guilib/LocalizeStrings.h" @@ -65,7 +65,7 @@ bool CGUIPassword::IsItemUnlocked(CFileItem* pItem, const CStdString &strType) } else { - if (0 != g_guiSettings.GetInt("masterlock.maxretries") && pItem->m_iBadPwdCount >= g_guiSettings.GetInt("masterlock.maxretries")) + if (0 != CSettings::Get().GetInt("masterlock.maxretries") && pItem->m_iBadPwdCount >= CSettings::Get().GetInt("masterlock.maxretries")) { // user previously exhausted all retries, show access denied error CGUIDialogOK::ShowAndGetInput(12345, 12346, 0, 0); return false; @@ -100,7 +100,7 @@ bool CGUIPassword::IsItemUnlocked(CFileItem* pItem, const CStdString &strType) case 1: { // password entry failed - if (0 != g_guiSettings.GetInt("masterlock.maxretries")) + if (0 != CSettings::Get().GetInt("masterlock.maxretries")) pItem->m_iBadPwdCount++; sprintf(buffer,"%i",pItem->m_iBadPwdCount); CMediaSourceSettings::Get().UpdateSource(strType, strLabel, "badpwdcount", buffer); @@ -124,7 +124,7 @@ bool CGUIPassword::CheckStartUpLock() int iVerifyPasswordResult = -1; CStdString strHeader = g_localizeStrings.Get(20075); if (iMasterLockRetriesLeft == -1) - iMasterLockRetriesLeft = g_guiSettings.GetInt("masterlock.maxretries"); + iMasterLockRetriesLeft = CSettings::Get().GetInt("masterlock.maxretries"); if (g_passwordManager.iMasterLockRetriesLeft == 0) g_passwordManager.iMasterLockRetriesLeft = 1; CStdString strPassword = CProfilesManager::Get().GetMasterProfile().getLockCode(); if (CProfilesManager::Get().GetMasterProfile().getLockMode() == 0) @@ -151,7 +151,7 @@ bool CGUIPassword::CheckStartUpLock() if (iVerifyPasswordResult == 0) { - g_passwordManager.iMasterLockRetriesLeft = g_guiSettings.GetInt("masterlock.maxretries"); + g_passwordManager.iMasterLockRetriesLeft = CSettings::Get().GetInt("masterlock.maxretries"); return true; // OK The MasterCode Accepted! XBMC Can Run! } else @@ -227,7 +227,7 @@ bool CGUIPassword::IsMasterLockUnlocked(bool bPromptUser, bool& bCanceled) { bCanceled = false; if (iMasterLockRetriesLeft == -1) - iMasterLockRetriesLeft = g_guiSettings.GetInt("masterlock.maxretries"); + iMasterLockRetriesLeft = CSettings::Get().GetInt("masterlock.maxretries"); if ((LOCK_MODE_EVERYONE < CProfilesManager::Get().GetMasterProfile().getLockMode() && !bMasterUser) && !bPromptUser) // not unlocked, but calling code doesn't want to prompt user return false; @@ -267,7 +267,7 @@ void CGUIPassword::UpdateMasterLockRetryCount(bool bResetCount) if (!bResetCount) { // Bad mastercode entered - if (0 < g_guiSettings.GetInt("masterlock.maxretries")) + if (0 < CSettings::Get().GetInt("masterlock.maxretries")) { // We're keeping track of how many bad passwords are entered if (1 < g_passwordManager.iMasterLockRetriesLeft) @@ -290,7 +290,7 @@ void CGUIPassword::UpdateMasterLockRetryCount(bool bResetCount) CGUIDialogOK::ShowAndGetInput(20075, 12345, dlgLine1, 0); } else - g_passwordManager.iMasterLockRetriesLeft = g_guiSettings.GetInt("masterlock.maxretries"); // user entered correct mastercode, reset retries to max allowed + g_passwordManager.iMasterLockRetriesLeft = CSettings::Get().GetInt("masterlock.maxretries"); // user entered correct mastercode, reset retries to max allowed } bool CGUIPassword::CheckLock(LockType btnType, const CStdString& strPassword, int iHeading) @@ -454,6 +454,16 @@ bool CGUIPassword::IsDatabasePathUnlocked(const CStdString& strPath, VECSOURCES& return false; } +void CGUIPassword::OnSettingAction(const CSetting *setting) +{ + if (setting == NULL) + return; + + const std::string &settingId = setting->GetId(); + if (settingId == "masterlock.lockcode") + SetMasterLockMode(); +} + int CGUIPassword::VerifyPassword(LockType btnType, const CStdString& strPassword, const CStdString& strHeading) { int iVerifyPasswordResult; diff --git a/xbmc/GUIPassword.h b/xbmc/GUIPassword.h index 09a4144c1f343..7719dd9992887 100644 --- a/xbmc/GUIPassword.h +++ b/xbmc/GUIPassword.h @@ -20,14 +20,15 @@ * */ +#include +#include + +#include "settings/ISettingCallback.h" #include "utils/StdString.h" class CFileItem; class CMediaSource; -#include -#include - typedef std::vector VECSOURCES; typedef enum @@ -41,7 +42,7 @@ typedef enum LOCK_MODE_EEPROM_PARENTAL = 5 } LockType; -class CGUIPassword +class CGUIPassword : public ISettingCallback { public: CGUIPassword(void); @@ -64,6 +65,8 @@ class CGUIPassword void RemoveSourceLocks(); bool IsDatabasePathUnlocked(const CStdString& strPath, VECSOURCES& vecSources); + virtual void OnSettingAction(const CSetting *setting); + bool bMasterUser; int iMasterLockRetriesLeft; diff --git a/xbmc/LangInfo.cpp b/xbmc/LangInfo.cpp index d60314ef2e9d7..2b1373199d7f1 100644 --- a/xbmc/LangInfo.cpp +++ b/xbmc/LangInfo.cpp @@ -19,14 +19,24 @@ */ #include "LangInfo.h" -#include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" +#include "Application.h" +#include "FileItem.h" +#include "Util.h" +#include "filesystem/Directory.h" +#include "guilib/GUIFontManager.h" #include "guilib/LocalizeStrings.h" +#include "pvr/PVRManager.h" +#include "settings/AdvancedSettings.h" +#include "settings/Settings.h" +#include "utils/CharsetConverter.h" #include "utils/log.h" -#include "utils/XBMCTinyXML.h" #include "utils/LangCodeExpander.h" +#include "utils/StringUtils.h" +#include "utils/Weather.h" +#include "utils/XBMCTinyXML.h" using namespace std; +using namespace PVR; #define TEMP_UNIT_STRINGS 20027 @@ -195,6 +205,28 @@ CLangInfo::~CLangInfo() { } +void CLangInfo::OnSettingChanged(const CSetting *setting) +{ + if (setting == NULL) + return; + + const std::string &settingId = setting->GetId(); + if (settingId == "locale.audiolanguage") + SetAudioLanguage(((CSettingString*)setting)->GetValue()); + else if (settingId == "locale.subtitlelanguage") + SetSubtitleLanguage(((CSettingString*)setting)->GetValue()); + else if (settingId == "locale.language") + { + if (!SetLanguage(((CSettingString*)setting)->GetValue())) + ((CSettingString*)CSettings::Get().GetSetting("locale.language"))->Reset(); + } + else if (settingId == "locale.country") + { + g_langInfo.SetCurrentRegion(((CSettingString*)setting)->GetValue()); + g_weatherManager.Refresh(); // need to reset our weather, as temperatures need re-translating. + } +} + bool CLangInfo::Load(const CStdString& strFileName) { SetDefaults(); @@ -328,7 +360,7 @@ bool CLangInfo::Load(const CStdString& strFileName) pRegion=pRegion->NextSiblingElement("region"); } - const CStdString& strName=g_guiSettings.GetString("locale.country"); + const CStdString& strName=CSettings::Get().GetString("locale.country"); SetCurrentRegion(strName); } @@ -376,7 +408,7 @@ void CLangInfo::SetDefaults() CStdString CLangInfo::GetGuiCharSet() const { CStdString strCharSet; - strCharSet=g_guiSettings.GetString("locale.charset"); + strCharSet=CSettings::Get().GetString("locale.charset"); if (strCharSet=="DEFAULT") strCharSet=m_currentRegion->m_strGuiCharSet; @@ -385,13 +417,40 @@ CStdString CLangInfo::GetGuiCharSet() const CStdString CLangInfo::GetSubtitleCharSet() const { - CStdString strCharSet=g_guiSettings.GetString("subtitles.charset"); + CStdString strCharSet=CSettings::Get().GetString("subtitles.charset"); if (strCharSet=="DEFAULT") strCharSet=m_currentRegion->m_strSubtitleCharSet; return strCharSet; } +bool CLangInfo::SetLanguage(const std::string &strLanguage) +{ + string strLangInfoPath = StringUtils::Format("special://xbmc/language/%s/langinfo.xml", strLanguage.c_str()); + if (!g_langInfo.Load(strLangInfoPath)) + return false; + + if (ForceUnicodeFont() && !g_fontManager.IsFontSetUnicode()) + { + CLog::Log(LOGINFO, "Language needs a ttf font, loading first ttf font available"); + CStdString strFontSet; + if (!g_fontManager.GetFirstFontSetUnicode(strFontSet)) + CLog::Log(LOGERROR, "No ttf font found but needed: %s", strFontSet.c_str()); + } + + g_charsetConverter.reset(); + + if (!g_localizeStrings.Load("special://xbmc/language/", strLanguage)) + return false; + + // also tell our weather and skin to reload as these are localized + g_weatherManager.Refresh(); + g_PVRManager.LocalizationChanged(); + g_application.ReloadSkin(); + + return true; +} + // three char language code (not win32 specific) const CStdString& CLangInfo::GetAudioLanguage() const { @@ -530,3 +589,64 @@ const CStdString& CLangInfo::GetSpeedUnitString() const { return g_localizeStrings.Get(SPEED_UNIT_STRINGS+m_currentRegion->m_speedUnit); } + +void CLangInfo::SettingOptionsLanguagesFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t) +{ + SettingOptionsLanguagesFillerGeneral(setting, list, current); +} + +void CLangInfo::SettingOptionsStreamLanguagesFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t) +{ + vector languages; + languages.push_back(g_localizeStrings.Get(308)); + languages.push_back(g_localizeStrings.Get(309)); + vector languageKeys; + languageKeys.push_back("original"); + languageKeys.push_back("default"); + SettingOptionsLanguagesFillerGeneral(setting, list, current, languages, languageKeys); +} + +void CLangInfo::SettingOptionsRegionsFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t) +{ + CStdStringArray regions; + g_langInfo.GetRegionNames(regions); + sort(regions.begin(), regions.end(), sortstringbyname()); + + for (unsigned int i = 0; i < regions.size(); ++i) + list.push_back(make_pair(regions[i], regions[i])); +} + +void CLangInfo::SettingOptionsLanguagesFillerGeneral(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t, + const std::vector &languages /* = std::vector() */, + const std::vector &languageKeys /* = std::vector() */) +{ + //find languages... + CFileItemList items; + XFILE::CDirectory::GetDirectory("special://xbmc/language/", items); + + vector vecLanguage; + for (int i = 0; i < items.Size(); ++i) + { + CFileItemPtr pItem = items[i]; + if (pItem->m_bIsFolder) + { + if (StringUtils::EqualsNoCase(pItem->GetLabel(), ".svn") || + StringUtils::EqualsNoCase(pItem->GetLabel(), "fonts") || + StringUtils::EqualsNoCase(pItem->GetLabel(), "media")) + continue; + + vecLanguage.push_back(pItem->GetLabel()); + } + } + + sort(vecLanguage.begin(), vecLanguage.end(), sortstringbyname()); + // Add language options passed by parameter at the beginning + if (languages.size() > 0) + { + for (unsigned int i = 0; i < languages.size(); ++i) + list.push_back(make_pair(languages[i], languageKeys[i])); + } + + for (unsigned int i = 0; i < vecLanguage.size(); ++i) + list.push_back(make_pair(vecLanguage[i], vecLanguage[i])); +} diff --git a/xbmc/LangInfo.h b/xbmc/LangInfo.h index 61e7160f472a4..1281c1ed86fbf 100644 --- a/xbmc/LangInfo.h +++ b/xbmc/LangInfo.h @@ -19,18 +19,21 @@ * */ +#include "settings/ISettingCallback.h" #include "utils/StdString.h" #include class TiXmlNode; -class CLangInfo +class CLangInfo : public ISettingCallback { public: CLangInfo(); virtual ~CLangInfo(); + virtual void OnSettingChanged(const CSetting *setting); + bool Load(const CStdString& strFileName); CStdString GetGuiCharSet() const; @@ -39,6 +42,8 @@ class CLangInfo // three char language code (not win32 specific) const CStdString& GetLanguageCode() const { return m_languageCodeGeneral; } + bool SetLanguage(const std::string &strLanguage); + const CStdString& GetAudioLanguage() const; // language can either be a two char language code as defined in ISO639 // or a three char language code @@ -114,11 +119,20 @@ class CLangInfo const CStdString& GetCurrentRegion() const; static void LoadTokens(const TiXmlNode* pTokens, std::vector& vecTokens); + + static void SettingOptionsLanguagesFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t); + static void SettingOptionsStreamLanguagesFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t); + static void SettingOptionsRegionsFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t); + protected: void SetDefaults(); protected: + static void SettingOptionsLanguagesFillerGeneral(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t, + const std::vector &languages = std::vector(), + const std::vector &languageKeys = std::vector()); + class CRegion { public: diff --git a/xbmc/NfoFile.cpp b/xbmc/NfoFile.cpp index f91367e0641aa..973e4d0e18e96 100644 --- a/xbmc/NfoFile.cpp +++ b/xbmc/NfoFile.cpp @@ -25,11 +25,10 @@ #include "video/VideoInfoDownloader.h" #include "addons/AddonManager.h" #include "filesystem/File.h" -#include "settings/GUISettings.h" #include "FileItem.h" #include "music/Album.h" #include "music/Artist.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/log.h" #include diff --git a/xbmc/SystemGlobals.cpp b/xbmc/SystemGlobals.cpp index 758e763a39592..987b7b7657a64 100644 --- a/xbmc/SystemGlobals.cpp +++ b/xbmc/SystemGlobals.cpp @@ -23,8 +23,6 @@ #include "Application.h" #include "GUILargeTextureManager.h" #include "guilib/TextureManager.h" -#include "settings/GUISettings.h" -#include "settings/Settings.h" #include "utils/AlarmClock.h" #include "utils/DownloadQueueManager.h" #include "GUIInfoManager.h" @@ -55,8 +53,6 @@ #include "linux/RBP.h" #endif - CSettings g_settings; - CXBMCRenderManager g_renderManager; CLangInfo g_langInfo; CLangCodeExpander g_LangCodeExpander; diff --git a/xbmc/TextureCacheJob.cpp b/xbmc/TextureCacheJob.cpp index 6f062c1a4a0d1..cffc70d8be6f4 100644 --- a/xbmc/TextureCacheJob.cpp +++ b/xbmc/TextureCacheJob.cpp @@ -23,7 +23,7 @@ #include "guilib/Texture.h" #include "guilib/DDSImage.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/log.h" #include "filesystem/File.h" #include "pictures/Picture.h" @@ -177,7 +177,7 @@ CBaseTexture *CTextureCacheJob::LoadImage(const CStdString &image, unsigned int && !file.GetMimeType().Left(6).Equals("image/") && !file.GetMimeType().Equals("application/octet-stream")) // ignore non-pictures return NULL; - CBaseTexture *texture = CBaseTexture::LoadFromFile(image, width, height, g_guiSettings.GetBool("pictures.useexifrotation")); + CBaseTexture *texture = CBaseTexture::LoadFromFile(image, width, height, CSettings::Get().GetBool("pictures.useexifrotation")); if (!texture) return NULL; diff --git a/xbmc/Util.cpp b/xbmc/Util.cpp index 3b670c877b662..123e103e263c5 100644 --- a/xbmc/Util.cpp +++ b/xbmc/Util.cpp @@ -59,7 +59,6 @@ #endif #include "profiles/ProfilesManager.h" #include "utils/RegExp.h" -#include "settings/GUISettings.h" #include "guilib/GraphicContext.h" #include "guilib/TextureManager.h" #include "utils/fstrcmp.h" @@ -74,6 +73,7 @@ #endif #include "GUIUserMessages.h" #include "filesystem/File.h" +#include "settings/MediaSettings.h" #include "settings/Settings.h" #include "utils/StringUtils.h" #include "settings/AdvancedSettings.h" @@ -220,7 +220,7 @@ CStdString CUtil::GetTitleFromPath(const CStdString& strFileNameAndPath, bool bI strFilename = URIUtils::GetFileName(url.GetHostName()); // now remove the extension if needed - if (!g_guiSettings.GetBool("filelists.showextensions") && !bIsFolder) + if (!CSettings::Get().GetBool("filelists.showextensions") && !bIsFolder) { URIUtils::RemoveExtension(strFilename); return strFilename; @@ -1029,7 +1029,7 @@ CStdString CUtil::ValidatePath(const CStdString &path, bool bFixDoubleSlashes /* bool CUtil::IsUsingTTFSubtitles() { - return URIUtils::GetExtension(g_guiSettings.GetString("subtitles.font")).Equals(".ttf"); + return URIUtils::GetExtension(CSettings::Get().GetString("subtitles.font")).Equals(".ttf"); } #ifdef UNIT_TESTING @@ -1343,7 +1343,7 @@ CStdString CUtil::TranslateSpecialSource(const CStdString &strSpecial) URIUtils::AddFileToFolder("special://cdrips/", strSpecial.Mid(7), strReturn); // this one will be removed post 2.0 else if (strSpecial.Left(10).Equals("$PLAYLISTS")) - URIUtils::AddFileToFolder(g_guiSettings.GetString("system.playlistspath",false), strSpecial.Mid(10), strReturn); + URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"), strSpecial.Mid(10), strReturn); } return strReturn; } @@ -1352,9 +1352,9 @@ CStdString CUtil::MusicPlaylistsLocation() { vector vec; CStdString strReturn; - URIUtils::AddFileToFolder(g_guiSettings.GetString("system.playlistspath"), "music", strReturn); + URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"), "music", strReturn); vec.push_back(strReturn); - URIUtils::AddFileToFolder(g_guiSettings.GetString("system.playlistspath"), "mixed", strReturn); + URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"), "mixed", strReturn); vec.push_back(strReturn); return XFILE::CMultiPathDirectory::ConstructMultiPath(vec);; } @@ -1363,9 +1363,9 @@ CStdString CUtil::VideoPlaylistsLocation() { vector vec; CStdString strReturn; - URIUtils::AddFileToFolder(g_guiSettings.GetString("system.playlistspath"), "video", strReturn); + URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"), "video", strReturn); vec.push_back(strReturn); - URIUtils::AddFileToFolder(g_guiSettings.GetString("system.playlistspath"), "mixed", strReturn); + URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"), "mixed", strReturn); vec.push_back(strReturn); return XFILE::CMultiPathDirectory::ConstructMultiPath(vec);; } @@ -1912,14 +1912,14 @@ void CUtil::ScanForExternalSubtitles(const CStdString& strMovie, std::vector dir. if (CMediaSettings::Get().GetAdditionalSubtitleDirectoryChecked() == 1) { - strPath = g_guiSettings.GetString("subtitles.custompath"); + strPath = CSettings::Get().GetString("subtitles.custompath"); URIUtils::AddSlashAtEnd(strPath); strLookInPaths.push_back(strPath); } @@ -2241,6 +2241,20 @@ bool CUtil::CanBindPrivileged() #endif //_LINUX } +bool CUtil::ValidatePort(int port) +{ + // check that it's a valid port +#ifdef _LINUX + if (!CUtil::CanBindPrivileged() && (port < 1024 || port > 65535)) + return false; + else +#endif + if (port <= 0 || port > 65535) + return false; + + return true; +} + int CUtil::GetRandomNumber() { #ifdef TARGET_WINDOWS diff --git a/xbmc/Util.h b/xbmc/Util.h index e9f1715d5fd71..6a902cab376cf 100644 --- a/xbmc/Util.h +++ b/xbmc/Util.h @@ -197,6 +197,7 @@ class CUtil static CStdString GetFrameworksPath(bool forPython = false); static bool CanBindPrivileged(); + static bool ValidatePort(int port); /*! * \brief Thread-safe random number generation diff --git a/xbmc/addons/Addon.cpp b/xbmc/addons/Addon.cpp index 1fbc27463b017..dea52875db330 100644 --- a/xbmc/addons/Addon.cpp +++ b/xbmc/addons/Addon.cpp @@ -20,7 +20,7 @@ #include "Addon.h" #include "AddonManager.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "filesystem/Directory.h" #include "filesystem/File.h" #include "interfaces/python/XBPython.h" @@ -411,7 +411,7 @@ bool CAddon::LoadStrings() // Path where the language strings reside CStdString chosenPath = URIUtils::AddFileToFolder(m_props.path, "resources/language/"); - m_hasStrings = m_strings.Load(chosenPath, g_guiSettings.GetString("locale.language")); + m_hasStrings = m_strings.Load(chosenPath, CSettings::Get().GetString("locale.language")); return m_checkedStrings = true; } diff --git a/xbmc/addons/Addon.h b/xbmc/addons/Addon.h index dac880ef94428..e3ba9af0e215d 100644 --- a/xbmc/addons/Addon.h +++ b/xbmc/addons/Addon.h @@ -107,7 +107,7 @@ class CAddon : public IAddon \return true if the addon has settings, false otherwise \sa LoadSettings, LoadUserSettings, SaveSettings, HasUserSettings, GetSetting, UpdateSetting */ - bool HasSettings(); + virtual bool HasSettings(); /*! \brief Check whether the user has configured this addon or not \return true if previously saved settings are found, false otherwise diff --git a/xbmc/addons/AddonCallbacksGUI.cpp b/xbmc/addons/AddonCallbacksGUI.cpp index ddbf3f62056ee..287414fa1a284 100644 --- a/xbmc/addons/AddonCallbacksGUI.cpp +++ b/xbmc/addons/AddonCallbacksGUI.cpp @@ -31,7 +31,6 @@ #include "guilib/GUIWindowManager.h" #include "guilib/Key.h" #include "guilib/TextureManager.h" -#include "settings/GUISettings.h" #include "guilib/GUISpinControlEx.h" #include "guilib/GUIRadioButtonControl.h" #include "guilib/GUISettingsSliderControl.h" diff --git a/xbmc/addons/AddonInstaller.cpp b/xbmc/addons/AddonInstaller.cpp index 7c426320510e9..2338b1d5ac53e 100644 --- a/xbmc/addons/AddonInstaller.cpp +++ b/xbmc/addons/AddonInstaller.cpp @@ -27,7 +27,7 @@ #include "guilib/LocalizeStrings.h" #include "filesystem/Directory.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "ApplicationMessenger.h" #include "Favourites.h" #include "utils/JobManager.h" @@ -553,7 +553,7 @@ bool CAddonInstallJob::DownloadPackage(const CStdString &path, const CStdString bool CAddonInstallJob::OnPreInstall() { // check whether this is an active skin - we need to unload it if so - if (g_guiSettings.GetString("lookandfeel.skin") == m_addon->ID()) + if (CSettings::Get().GetString("lookandfeel.skin") == m_addon->ID()) { CApplicationMessenger::Get().ExecBuiltIn("UnloadSkin", true); return true; @@ -654,7 +654,7 @@ bool CAddonInstallJob::Install(const CStdString &installFrom) void CAddonInstallJob::OnPostInstall(bool reloadAddon) { - if (m_addon->Type() < ADDON_VIZ_LIBRARY && g_guiSettings.GetBool("general.addonnotifications")) + if (m_addon->Type() < ADDON_VIZ_LIBRARY && CSettings::Get().GetBool("general.addonnotifications")) { CGUIDialogKaiToast::QueueNotification(m_addon->Icon(), m_addon->Name(), @@ -667,7 +667,7 @@ void CAddonInstallJob::OnPostInstall(bool reloadAddon) if (reloadAddon || (!m_update && CGUIDialogYesNo::ShowAndGetInput(m_addon->Name(), g_localizeStrings.Get(24099),"",""))) { - g_guiSettings.SetString("lookandfeel.skin",m_addon->ID().c_str()); + CSettings::Get().SetString("lookandfeel.skin",m_addon->ID().c_str()); CGUIDialogKaiToast *toast = (CGUIDialogKaiToast *)g_windowManager.GetWindow(WINDOW_DIALOG_KAI_TOAST); if (toast) { @@ -805,7 +805,7 @@ void CAddonUnInstallJob::OnPostUnInstall() if (m_addon->Type() == ADDON_PVRDLL) { - if (g_guiSettings.GetBool("pvrmanager.enabled")) + if (CSettings::Get().GetBool("pvrmanager.enabled")) PVR::CPVRManager::Get().Start(true); } } diff --git a/xbmc/addons/AddonManager.cpp b/xbmc/addons/AddonManager.cpp index 38c304b7c6979..e40fe877fe785 100644 --- a/xbmc/addons/AddonManager.cpp +++ b/xbmc/addons/AddonManager.cpp @@ -25,8 +25,8 @@ #include "threads/SingleLock.h" #include "FileItem.h" #include "LangInfo.h" -#include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" +#include "settings/Settings.h" #include "utils/log.h" #include "utils/XBMCTinyXML.h" #ifdef HAS_VISUALISATION @@ -473,28 +473,28 @@ bool CAddonMgr::GetDefault(const TYPE &type, AddonPtr &addon) switch (type) { case ADDON_VIZ: - setting = g_guiSettings.GetString("musicplayer.visualisation"); + setting = CSettings::Get().GetString("musicplayer.visualisation"); break; case ADDON_SCREENSAVER: - setting = g_guiSettings.GetString("screensaver.mode"); + setting = CSettings::Get().GetString("screensaver.mode"); break; case ADDON_SCRAPER_ALBUMS: - setting = g_guiSettings.GetString("musiclibrary.albumsscraper"); + setting = CSettings::Get().GetString("musiclibrary.albumsscraper"); break; case ADDON_SCRAPER_ARTISTS: - setting = g_guiSettings.GetString("musiclibrary.artistsscraper"); + setting = CSettings::Get().GetString("musiclibrary.artistsscraper"); break; case ADDON_SCRAPER_MOVIES: - setting = g_guiSettings.GetString("scrapers.moviesdefault"); + setting = CSettings::Get().GetString("scrapers.moviesdefault"); break; case ADDON_SCRAPER_MUSICVIDEOS: - setting = g_guiSettings.GetString("scrapers.musicvideosdefault"); + setting = CSettings::Get().GetString("scrapers.musicvideosdefault"); break; case ADDON_SCRAPER_TVSHOWS: - setting = g_guiSettings.GetString("scrapers.tvshowsdefault"); + setting = CSettings::Get().GetString("scrapers.tvshowsdefault"); break; case ADDON_WEB_INTERFACE: - setting = g_guiSettings.GetString("services.webskin"); + setting = CSettings::Get().GetString("services.webskin"); break; default: return false; @@ -507,25 +507,25 @@ bool CAddonMgr::SetDefault(const TYPE &type, const CStdString &addonID) switch (type) { case ADDON_VIZ: - g_guiSettings.SetString("musicplayer.visualisation",addonID); + CSettings::Get().SetString("musicplayer.visualisation",addonID); break; case ADDON_SCREENSAVER: - g_guiSettings.SetString("screensaver.mode",addonID); + CSettings::Get().SetString("screensaver.mode",addonID); break; case ADDON_SCRAPER_ALBUMS: - g_guiSettings.SetString("musiclibrary.albumsscraper",addonID); + CSettings::Get().SetString("musiclibrary.albumsscraper",addonID); break; case ADDON_SCRAPER_ARTISTS: - g_guiSettings.SetString("musiclibrary.artistsscraper",addonID); + CSettings::Get().SetString("musiclibrary.artistsscraper",addonID); break; case ADDON_SCRAPER_MOVIES: - g_guiSettings.SetString("scrapers.moviesdefault",addonID); + CSettings::Get().SetString("scrapers.moviesdefault",addonID); break; case ADDON_SCRAPER_MUSICVIDEOS: - g_guiSettings.SetString("scrapers.musicvideosdefault",addonID); + CSettings::Get().SetString("scrapers.musicvideosdefault",addonID); break; case ADDON_SCRAPER_TVSHOWS: - g_guiSettings.SetString("scrapers.tvshowsdefault",addonID); + CSettings::Get().SetString("scrapers.tvshowsdefault",addonID); break; default: return false; diff --git a/xbmc/addons/AddonStatusHandler.cpp b/xbmc/addons/AddonStatusHandler.cpp index 6d4d1f6111fc7..874461be97a92 100644 --- a/xbmc/addons/AddonStatusHandler.cpp +++ b/xbmc/addons/AddonStatusHandler.cpp @@ -26,7 +26,7 @@ #include "dialogs/GUIDialogYesNo.h" #include "dialogs/GUIDialogOK.h" #include "dialogs/GUIDialogKaiToast.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/log.h" namespace ADDON @@ -89,7 +89,7 @@ void CAddonStatusHandler::Process() { if (m_addon->Type() == ADDON_PVRDLL) { - if (!g_guiSettings.GetBool("pvrmanager.hideconnectionlostwarning")) + if (!CSettings::Get().GetBool("pvrmanager.hideconnectionlostwarning")) CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, m_addon->Name().c_str(), g_localizeStrings.Get(36030)); // connection lost // TODO handle disconnects after the add-on's been initialised } diff --git a/xbmc/addons/GUIWindowAddonBrowser.cpp b/xbmc/addons/GUIWindowAddonBrowser.cpp index 8fbd83dbe248e..e6303e2a75e52 100644 --- a/xbmc/addons/GUIWindowAddonBrowser.cpp +++ b/xbmc/addons/GUIWindowAddonBrowser.cpp @@ -39,12 +39,12 @@ #include "utils/log.h" #include "threads/SingleLock.h" #include "settings/Settings.h" +#include "settings/MediaSourceSettings.h" #include "utils/StringUtils.h" #include "AddonDatabase.h" #include "settings/AdvancedSettings.h" #include "settings/MediaSourceSettings.h" #include "storage/MediaManager.h" -#include "settings/GUISettings.h" #include "LangInfo.h" #include "guilib/Key.h" @@ -90,20 +90,19 @@ bool CGUIWindowAddonBrowser::OnMessage(CGUIMessage& message) int iControl = message.GetSenderId(); if (iControl == CONTROL_AUTOUPDATE) { - g_guiSettings.ToggleBool("general.addonautoupdate"); - g_settings.Save(); + CSettings::Get().ToggleBool("general.addonautoupdate"); return true; } else if (iControl == CONTROL_SHUTUP) { - g_guiSettings.ToggleBool("general.addonnotifications"); - g_settings.Save(); + CSettings::Get().ToggleBool("general.addonnotifications"); + CSettings::Get().Save(); return true; } else if (iControl == CONTROL_FOREIGNFILTER) { - g_guiSettings.ToggleBool("general.addonforeignfilter"); - g_settings.Save(); + CSettings::Get().ToggleBool("general.addonforeignfilter"); + CSettings::Get().Save(); Refresh(); return true; } @@ -251,9 +250,9 @@ bool CGUIWindowAddonBrowser::OnClick(int iItem) void CGUIWindowAddonBrowser::UpdateButtons() { - SET_CONTROL_SELECTED(GetID(),CONTROL_AUTOUPDATE,g_guiSettings.GetBool("general.addonautoupdate")); - SET_CONTROL_SELECTED(GetID(),CONTROL_SHUTUP,g_guiSettings.GetBool("general.addonnotifications")); - SET_CONTROL_SELECTED(GetID(),CONTROL_FOREIGNFILTER,g_guiSettings.GetBool("general.addonforeignfilter")); + SET_CONTROL_SELECTED(GetID(),CONTROL_AUTOUPDATE, CSettings::Get().GetBool("general.addonautoupdate")); + SET_CONTROL_SELECTED(GetID(),CONTROL_SHUTUP, CSettings::Get().GetBool("general.addonnotifications")); + SET_CONTROL_SELECTED(GetID(),CONTROL_FOREIGNFILTER, CSettings::Get().GetBool("general.addonforeignfilter")); CGUIMediaWindow::UpdateButtons(); } @@ -298,14 +297,14 @@ bool CGUIWindowAddonBrowser::GetDirectory(const CStdString& strDirectory, else { result = CGUIMediaWindow::GetDirectory(strDirectory,items); - if (g_guiSettings.GetBool("general.addonforeignfilter")) + if (CSettings::Get().GetBool("general.addonforeignfilter")) { int i=0; while (i < items.Size()) { - if (!FilterVar(g_guiSettings.GetBool("general.addonforeignfilter"), + if (!FilterVar(CSettings::Get().GetBool("general.addonforeignfilter"), items[i]->GetProperty("Addon.Language"), "en") || - !FilterVar(g_guiSettings.GetBool("general.addonforeignfilter"), + !FilterVar(CSettings::Get().GetBool("general.addonforeignfilter"), items[i]->GetProperty("Addon.Language"), g_langInfo.GetLanguageLocale())) { diff --git a/xbmc/addons/Repository.cpp b/xbmc/addons/Repository.cpp index e58024d18038a..580fa91de1aa2 100644 --- a/xbmc/addons/Repository.cpp +++ b/xbmc/addons/Repository.cpp @@ -22,7 +22,7 @@ #include "utils/XBMCTinyXML.h" #include "filesystem/File.h" #include "AddonDatabase.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "FileItem.h" #include "utils/JobManager.h" #include "addons/AddonInstaller.h" @@ -222,7 +222,7 @@ bool CRepositoryUpdateJob::DoWork() if (addon && addons[i]->Version() > addon->Version() && !database.IsAddonBlacklisted(addons[i]->ID(),addons[i]->Version().c_str())) { - if (g_guiSettings.GetBool("general.addonautoupdate") || addon->Type() >= ADDON_VIZ_LIBRARY) + if (CSettings::Get().GetBool("general.addonautoupdate") || addon->Type() >= ADDON_VIZ_LIBRARY) { CStdString referer; if (URIUtils::IsInternetStream(addons[i]->Path())) @@ -234,7 +234,7 @@ bool CRepositoryUpdateJob::DoWork() else CAddonInstaller::Get().Install(addon->ID(), true, referer); } - else if (g_guiSettings.GetBool("general.addonnotifications")) + else if (CSettings::Get().GetBool("general.addonnotifications")) { CGUIDialogKaiToast::QueueNotification(addon->Icon(), g_localizeStrings.Get(24061), diff --git a/xbmc/addons/Skin.cpp b/xbmc/addons/Skin.cpp index a6beb4a143b1f..7ae1736f94a38 100644 --- a/xbmc/addons/Skin.cpp +++ b/xbmc/addons/Skin.cpp @@ -20,13 +20,15 @@ #include "Skin.h" #include "AddonManager.h" +#include "LangInfo.h" +#include "Util.h" #include "filesystem/File.h" #include "filesystem/SpecialProtocol.h" #include "guilib/WindowIDs.h" +#include "settings/Settings.h" #include "utils/URIUtils.h" #include "utils/log.h" #include "utils/StringUtils.h" -#include "settings/GUISettings.h" // fallback for new skin resolution code #include "filesystem/Directory.h" @@ -99,6 +101,11 @@ CSkinInfo::~CSkinInfo() { } +bool CSkinInfo::HasSettings() +{ + return HasSkinFile("SkinSettings.xml"); +} + struct closestRes { closestRes(const RESOLUTION_INFO &target) : m_target(target) { }; @@ -197,7 +204,7 @@ void CSkinInfo::ResolveIncludes(TiXmlElement *node, std::map* xmlIncl int CSkinInfo::GetStartWindow() const { - int windowID = g_guiSettings.GetInt("lookandfeel.startupwindow"); + int windowID = CSettings::Get().GetInt("lookandfeel.startupwindow"); assert(m_startupWindows.size()); for (vector::const_iterator it = m_startupWindows.begin(); it != m_startupWindows.end(); it++) { @@ -263,7 +270,7 @@ int CSkinInfo::GetFirstWindow() const bool CSkinInfo::IsInUse() const { // Could extend this to prompt for reverting to the standard skin perhaps - return g_guiSettings.GetString("lookandfeel.skin") == ID(); + return CSettings::Get().GetString("lookandfeel.skin") == ID(); } const INFO::CSkinVariableString* CSkinInfo::CreateSkinVariable(const CStdString& name, int context) @@ -271,4 +278,167 @@ const INFO::CSkinVariableString* CSkinInfo::CreateSkinVariable(const CStdString& return m_includes.CreateSkinVariable(name, context); } +void CSkinInfo::SettingOptionsSkinColorsFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t) +{ + // There is a default theme (just defaults.xml) + // any other *.xml files are additional color themes on top of this one. + + // add the default label + list.push_back(make_pair(g_localizeStrings.Get(15109), "SKINDEFAULT")); // the standard defaults.xml will be used! + + // Search for colors in the Current skin! + vector vecColors; + string strPath = URIUtils::AddFileToFolder(g_SkinInfo->Path(), "colors"); + + CFileItemList items; + CDirectory::GetDirectory(CSpecialProtocol::TranslatePathConvertCase(strPath), items, ".xml"); + // Search for Themes in the Current skin! + for (int i = 0; i < items.Size(); ++i) + { + CFileItemPtr pItem = items[i]; + if (!pItem->m_bIsFolder && !StringUtils::EqualsNoCase(pItem->GetLabel(), "defaults.xml")) + { // not the default one + vecColors.push_back(pItem->GetLabel().Mid(0, pItem->GetLabel().size() - 4)); + } + } + sort(vecColors.begin(), vecColors.end(), sortstringbyname()); + + for (int i = 0; i < (int) vecColors.size(); ++i) + list.push_back(make_pair(vecColors[i], vecColors[i])); + + CStdString settingValue = ((const CSettingString*)setting)->GetValue(); + // Remove the .xml extension from the Themes + if (URIUtils::GetExtension(settingValue) == ".xml") + URIUtils::RemoveExtension(settingValue); + + // Set the choosen theme + current = settingValue; +} + +void CSkinInfo::SettingOptionsSkinFontsFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t) +{ + std::string strPath = g_SkinInfo->GetSkinPath("Font.xml"); + + CXBMCTinyXML xmlDoc; + if (!xmlDoc.LoadFile(strPath)) + { + CLog::Log(LOGERROR, "FillInSkinFonts: Couldn't load %s", strPath.c_str()); + return; + } + + TiXmlElement* pRootElement = xmlDoc.RootElement(); + + std::string strValue = pRootElement->ValueStr(); + if (strValue != "fonts") + { + CLog::Log(LOGERROR, "FillInSkinFonts: file %s doesn't start with ", strPath.c_str()); + return; + } + + const TiXmlNode *pChild = pRootElement->FirstChild(); + strValue = pChild->ValueStr(); + if (strValue == "fontset") + { + while (pChild) + { + strValue = pChild->ValueStr(); + if (strValue == "fontset") + { + const char* idAttr = ((TiXmlElement*) pChild)->Attribute("id"); + const char* idLocAttr = ((TiXmlElement*) pChild)->Attribute("idloc"); + const char* unicodeAttr = ((TiXmlElement*) pChild)->Attribute("unicode"); + + bool isUnicode = (unicodeAttr && stricmp(unicodeAttr, "true") == 0); + + bool isAllowed = true; + if (g_langInfo.ForceUnicodeFont() && !isUnicode) + isAllowed = false; + + if (idAttr != NULL && isAllowed) + { + if (idLocAttr) + list.push_back(make_pair(g_localizeStrings.Get(atoi(idLocAttr)), idAttr)); + else + list.push_back(make_pair(idAttr, idAttr)); + } + } + + pChild = pChild->NextSibling(); + } + } + else + { + // Since no fontset is defined, there is no selection of a fontset, so disable the component + list.push_back(make_pair(g_localizeStrings.Get(13278), "")); + } +} + +void CSkinInfo::SettingOptionsSkinSoundFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t) +{ + //find skins... + CFileItemList items; + CDirectory::GetDirectory("special://xbmc/sounds/", items); + CDirectory::GetDirectory("special://home/sounds/", items); + + vector vecSoundSkins; + for (int i = 0; i < items.Size(); i++) + { + CFileItemPtr pItem = items[i]; + if (pItem->m_bIsFolder) + { + if (StringUtils::EqualsNoCase(pItem->GetLabel(), ".svn") || + StringUtils::EqualsNoCase(pItem->GetLabel(), "fonts") || + StringUtils::EqualsNoCase(pItem->GetLabel(), "media")) + continue; + + vecSoundSkins.push_back(pItem->GetLabel()); + } + } + + list.push_back(make_pair(g_localizeStrings.Get(474), "OFF")); + list.push_back(make_pair(g_localizeStrings.Get(15109), "SKINDEFAULT")); + + sort(vecSoundSkins.begin(), vecSoundSkins.end(), sortstringbyname()); + for (unsigned int i = 0; i < vecSoundSkins.size(); i++) + list.push_back(make_pair(vecSoundSkins[i], vecSoundSkins[i])); +} + +void CSkinInfo::SettingOptionsSkinThemesFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t) +{ + // there is a default theme (just Textures.xpr/xbt) + // any other *.xpr|*.xbt files are additional themes on top of this one. + const CSettingString *pSettingString = (const CSettingString *)setting; + + // add the default Label + list.push_back(make_pair(g_localizeStrings.Get(15109), "SKINDEFAULT")); // the standard Textures.xpr/xbt will be used + + // search for themes in the current skin! + vector vecTheme; + CUtil::GetSkinThemes(vecTheme); + + // sort the themes for GUI and list them + for (int i = 0; i < (int) vecTheme.size(); ++i) + list.push_back(make_pair(vecTheme[i], vecTheme[i])); + + // set the choosen theme and remove the extension from the current theme (backward compat) + CStdString settingValue = pSettingString->GetValue(); + URIUtils::RemoveExtension(settingValue); + current = settingValue; +} + +void CSkinInfo::SettingOptionsStartupWindowsFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t) +{ + const vector &startupWindows = g_SkinInfo->GetStartupWindows(); + + for (vector::const_iterator it = startupWindows.begin(); it != startupWindows.end(); it++) + { + string windowName = it->m_name; + if (StringUtils::IsNaturalNumber(windowName)) + windowName = g_localizeStrings.Get(atoi(windowName.c_str())); + int windowID = it->m_id; + + list.push_back(make_pair(windowName, windowID)); + } +} + } /*namespace ADDON*/ diff --git a/xbmc/addons/Skin.h b/xbmc/addons/Skin.h index 6666346d76bb0..c569dcb2b913c 100644 --- a/xbmc/addons/Skin.h +++ b/xbmc/addons/Skin.h @@ -20,12 +20,15 @@ * */ +#include + #include "Addon.h" #include "guilib/GraphicContext.h" // needed for the RESOLUTION members #include "guilib/GUIIncludes.h" // needed for the GUIInclude member #define CREDIT_LINE_LENGTH 50 class TiXmlNode; +class CSetting; namespace ADDON { @@ -49,6 +52,8 @@ class CSkinInfo : public CAddon CSkinInfo(const cp_extension_t *ext); virtual ~CSkinInfo(); + virtual bool HasSettings(); + /*! \brief Load resultion information from directories in Path(). */ void Start(); @@ -110,6 +115,13 @@ class CSkinInfo : public CAddon static double GetMinVersion(); void LoadIncludes(); const INFO::CSkinVariableString* CreateSkinVariable(const CStdString& name, int context); + + static void SettingOptionsSkinColorsFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t); + static void SettingOptionsSkinFontsFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t); + static void SettingOptionsSkinSoundFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t); + static void SettingOptionsSkinThemesFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t); + static void SettingOptionsStartupWindowsFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t); + protected: /*! \brief Given a resolution, retrieve the corresponding directory name \param res RESOLUTION to translate diff --git a/xbmc/addons/Visualisation.cpp b/xbmc/addons/Visualisation.cpp index e4dccbe399013..ee672a90a454a 100644 --- a/xbmc/addons/Visualisation.cpp +++ b/xbmc/addons/Visualisation.cpp @@ -26,6 +26,7 @@ #include "settings/DisplaySettings.h" #include "settings/Settings.h" #include "settings/AdvancedSettings.h" +#include "settings/DisplaySettings.h" #include "windowing/WindowingFactory.h" #include "utils/URIUtils.h" #include "utils/StringUtils.h" diff --git a/xbmc/cdrip/CDDARipJob.cpp b/xbmc/cdrip/CDDARipJob.cpp index 258f6100cedfa..9b8f9c168f174 100644 --- a/xbmc/cdrip/CDDARipJob.cpp +++ b/xbmc/cdrip/CDDARipJob.cpp @@ -38,7 +38,6 @@ #include "guilib/LocalizeStrings.h" #include "settings/AdvancedSettings.h" #include "utils/StringUtils.h" -#include "settings/GUISettings.h" #include "storage/MediaManager.h" using namespace MUSIC_INFO; diff --git a/xbmc/cdrip/CDDARipJob.h b/xbmc/cdrip/CDDARipJob.h index 04392106a5695..adb2c08631984 100644 --- a/xbmc/cdrip/CDDARipJob.h +++ b/xbmc/cdrip/CDDARipJob.h @@ -37,7 +37,7 @@ class CCDDARipJob : public CJob //! \param input The input file url //! \param output The output file url //! \param tag The music tag to attach to track - //! \param encoder The encoder to use. See GUISettings.h + //! \param encoder The encoder to use. See Encoder.h //! \param eject Should we eject tray on finish? //! \param rate The sample rate of the input //! \param channels Number of audio channels in input diff --git a/xbmc/cdrip/CDDARipper.cpp b/xbmc/cdrip/CDDARipper.cpp index 25507ea192c2d..9ce5b0256890d 100644 --- a/xbmc/cdrip/CDDARipper.cpp +++ b/xbmc/cdrip/CDDARipper.cpp @@ -33,8 +33,10 @@ #include "music/tags/MusicInfoTag.h" #include "guilib/GUIWindowManager.h" #include "dialogs/GUIDialogOK.h" -#include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" +#include "settings/SettingPath.h" +#include "settings/Settings.h" +#include "settings/windows/GUIControlSettings.h" #include "FileItem.h" #include "filesystem/SpecialProtocol.h" #include "storage/MediaManager.h" @@ -84,7 +86,7 @@ bool CCDDARipper::RipTrack(CFileItem* pItem) AddJob(new CCDDARipJob(pItem->GetPath(),strFile, *pItem->GetMusicInfoTag(), - g_guiSettings.GetInt("audiocds.encoder"))); + CSettings::Get().GetInt("audiocds.encoder"))); return true; } @@ -136,11 +138,11 @@ bool CCDDARipper::RipCD() if (item->GetPath().Find(".cdda") < 0) continue; - bool eject = g_guiSettings.GetBool("audiocds.ejectonrip") && + bool eject = CSettings::Get().GetBool("audiocds.ejectonrip") && i == vecItems.Size()-1; AddJob(new CCDDARipJob(item->GetPath(),strFile, *item->GetMusicInfoTag(), - g_guiSettings.GetInt("audiocds.encoder"), eject)); + CSettings::Get().GetInt("audiocds.encoder"), eject)); } return true; @@ -156,7 +158,16 @@ const char* CCDDARipper::GetExtension(int iEncoder) bool CCDDARipper::CreateAlbumDir(const MUSIC_INFO::CMusicInfoTag& infoTag, CStdString& strDirectory, int& legalType) { - strDirectory = g_guiSettings.GetString("audiocds.recordingpath"); + CSettingPath *recordingpathSetting = (CSettingPath*)CSettings::Get().GetSetting("audiocds.recordingpath"); + if (recordingpathSetting != NULL) + { + strDirectory = recordingpathSetting->GetValue(); + if (strDirectory.empty()) + { + if (CGUIControlButtonSetting::GetPath(recordingpathSetting)) + strDirectory = recordingpathSetting->GetValue(); + } + } URIUtils::AddSlashAtEnd(strDirectory); if (strDirectory.size() < 3) @@ -205,7 +216,7 @@ CStdString CCDDARipper::GetAlbumDirName(const MUSIC_INFO::CMusicInfoTag& infoTag // use audiocds.trackpathformat setting to format // directory name where CD tracks will be stored, // use only format part ending at the last '/' - strAlbumDir = g_guiSettings.GetString("audiocds.trackpathformat"); + strAlbumDir = CSettings::Get().GetString("audiocds.trackpathformat"); int pos = max(strAlbumDir.ReverseFind('/'), strAlbumDir.ReverseFind('\\')); if (pos < 0) return ""; // no directory @@ -272,7 +283,7 @@ CStdString CCDDARipper::GetTrackName(CFileItem *item) // get track file name format from audiocds.trackpathformat setting, // use only format part starting from the last '/' - CStdString strFormat = g_guiSettings.GetString("audiocds.trackpathformat"); + CStdString strFormat = CSettings::Get().GetString("audiocds.trackpathformat"); int pos = max(strFormat.ReverseFind('/'), strFormat.ReverseFind('\\')); if (pos != -1) { @@ -286,7 +297,7 @@ CStdString CCDDARipper::GetTrackName(CFileItem *item) CStdString track = destItem.GetLabel(); if (track.IsEmpty()) track.Format("%s%02i", "Track-", trackNumber); - track += GetExtension(g_guiSettings.GetInt("audiocds.encoder")); + track += GetExtension(CSettings::Get().GetInt("audiocds.encoder")); return track; } diff --git a/xbmc/cdrip/Encoder.h b/xbmc/cdrip/Encoder.h index 54f9d1bbe37aa..a4e920fe85fcf 100644 --- a/xbmc/cdrip/Encoder.h +++ b/xbmc/cdrip/Encoder.h @@ -33,6 +33,22 @@ #define WRITEBUFFER_SIZE 131072 // 128k buffer +enum CDDARipEncoder +{ + CDDARIP_ENCODER_LAME = 0, + CDDARIP_ENCODER_VORBIS, + CDDARIP_ENCODER_WAV, + CDDARIP_ENCODER_FLAC +}; + +enum CDDARipQuality +{ + CDDARIP_QUALITY_CBR = 0, + CDDARIP_QUALITY_MEDIUM, + CDDARIP_QUALITY_STANDARD, + CDDARIP_QUALITY_EXTREME +}; + namespace XFILE { class CFile; } class CEncoder diff --git a/xbmc/cdrip/EncoderFFmpeg.cpp b/xbmc/cdrip/EncoderFFmpeg.cpp index bd314024d89e7..30c9be31517b7 100644 --- a/xbmc/cdrip/EncoderFFmpeg.cpp +++ b/xbmc/cdrip/EncoderFFmpeg.cpp @@ -33,7 +33,7 @@ #include "EncoderFFmpeg.h" #include "filesystem/File.h" #include "utils/log.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/URIUtils.h" /* AV_PKT_FLAG_KEY was named PKT_FLAG_KEY in older versions of libavcodec */ @@ -86,7 +86,7 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int } m_Format->oformat = fmt; - m_Format->bit_rate = g_guiSettings.GetInt("audiocds.bitrate") * 1000; + m_Format->bit_rate = CSettings::Get().GetInt("audiocds.bitrate") * 1000; /* add a stream to it */ m_Stream = m_dllAvFormat.avformat_new_stream(m_Format, codec); diff --git a/xbmc/cdrip/EncoderFlac.cpp b/xbmc/cdrip/EncoderFlac.cpp index 49a11cc215f24..bab4532ad3b0a 100644 --- a/xbmc/cdrip/EncoderFlac.cpp +++ b/xbmc/cdrip/EncoderFlac.cpp @@ -21,7 +21,7 @@ #include "EncoderFlac.h" #include "utils/log.h" #include "filesystem/File.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" CEncoderFlac::CEncoderFlac() : m_encoder(0), m_samplesBuf(new FLAC__int32[SAMPLES_BUF_SIZE]) { @@ -63,7 +63,7 @@ bool CEncoderFlac::Init(const char* strFile, int iInChannels, int iInRate, int i ok &= m_dll.FLAC__stream_encoder_set_bits_per_sample(m_encoder, 16); ok &= m_dll.FLAC__stream_encoder_set_sample_rate(m_encoder, 44100); ok &= m_dll.FLAC__stream_encoder_set_total_samples_estimate(m_encoder, m_iTrackLength / 4); - ok &= m_dll.FLAC__stream_encoder_set_compression_level(m_encoder, g_guiSettings.GetInt("audiocds.compressionlevel")); + ok &= m_dll.FLAC__stream_encoder_set_compression_level(m_encoder, CSettings::Get().GetInt("audiocds.compressionlevel")); // now add some metadata FLAC__StreamMetadata_VorbisComment_Entry entry; diff --git a/xbmc/cdrip/EncoderLame.cpp b/xbmc/cdrip/EncoderLame.cpp index 3a03f7b166a4c..a1b359b7317d3 100644 --- a/xbmc/cdrip/EncoderLame.cpp +++ b/xbmc/cdrip/EncoderLame.cpp @@ -19,7 +19,7 @@ */ #include "EncoderLame.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/log.h" #ifdef _WIN32 @@ -54,9 +54,9 @@ bool CEncoderLame::Init(const char* strFile, int iInChannels, int iInRate, int i } // setup parmaters, see lame.h for possibilities - if (g_guiSettings.GetInt("audiocds.quality") == CDDARIP_QUALITY_CBR) + if (CSettings::Get().GetInt("audiocds.quality") == CDDARIP_QUALITY_CBR) { - int bitrate = g_guiSettings.GetInt("audiocds.bitrate"); + int bitrate = CSettings::Get().GetInt("audiocds.bitrate"); // use cbr and specified bitrate from settings CLog::Log(LOGDEBUG, "Lame setting CBR bitrate %d", bitrate); m_dll.lame_set_brate(m_pGlobalFlags, bitrate); @@ -65,7 +65,7 @@ bool CEncoderLame::Init(const char* strFile, int iInChannels, int iInRate, int i { // use presets (VBR) int preset; - switch (g_guiSettings.GetInt("audiocds.quality")) + switch (CSettings::Get().GetInt("audiocds.quality")) { case CDDARIP_QUALITY_MEDIUM: preset = MEDIUM; diff --git a/xbmc/cdrip/EncoderVorbis.cpp b/xbmc/cdrip/EncoderVorbis.cpp index cb23269542137..f1b81a17e0b0d 100644 --- a/xbmc/cdrip/EncoderVorbis.cpp +++ b/xbmc/cdrip/EncoderVorbis.cpp @@ -19,7 +19,7 @@ */ #include "EncoderVorbis.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/log.h" CEncoderVorbis::CEncoderVorbis() @@ -36,9 +36,9 @@ bool CEncoderVorbis::Init(const char* strFile, int iInChannels, int iInRate, int if (!CEncoder::Init(strFile, iInChannels, iInRate, iInBits)) return false; float fQuality = 0.5f; - if (g_guiSettings.GetInt("audiocds.quality") == CDDARIP_QUALITY_MEDIUM) fQuality = 0.4f; - if (g_guiSettings.GetInt("audiocds.quality") == CDDARIP_QUALITY_STANDARD) fQuality = 0.5f; - if (g_guiSettings.GetInt("audiocds.quality") == CDDARIP_QUALITY_EXTREME) fQuality = 0.7f; + if (CSettings::Get().GetInt("audiocds.quality") == CDDARIP_QUALITY_MEDIUM) fQuality = 0.4f; + if (CSettings::Get().GetInt("audiocds.quality") == CDDARIP_QUALITY_STANDARD) fQuality = 0.5f; + if (CSettings::Get().GetInt("audiocds.quality") == CDDARIP_QUALITY_EXTREME) fQuality = 0.7f; if (!m_VorbisEncDll.Load() || !m_OggDll.Load() || !m_VorbisDll.Load()) { @@ -48,10 +48,10 @@ bool CEncoderVorbis::Init(const char* strFile, int iInChannels, int iInRate, int } m_VorbisDll.vorbis_info_init(&m_sVorbisInfo); - if (g_guiSettings.GetInt("audiocds.quality") == CDDARIP_QUALITY_CBR) + if (CSettings::Get().GetInt("audiocds.quality") == CDDARIP_QUALITY_CBR) { // not realy cbr, but abr in this case - int iBitRate = g_guiSettings.GetInt("audiocds.bitrate") * 1000; + int iBitRate = CSettings::Get().GetInt("audiocds.bitrate") * 1000; m_VorbisEncDll.vorbis_encode_init(&m_sVorbisInfo, m_iInChannels, m_iInSampleRate, -1, iBitRate, -1); } else diff --git a/xbmc/cores/AudioEngine/AEFactory.cpp b/xbmc/cores/AudioEngine/AEFactory.cpp index 8c0cbb6e09f20..ad2fe27f004b5 100644 --- a/xbmc/cores/AudioEngine/AEFactory.cpp +++ b/xbmc/cores/AudioEngine/AEFactory.cpp @@ -20,9 +20,11 @@ #include "system.h" #include "AEFactory.h" +#include "Utils/AEUtil.h" #if defined(TARGET_DARWIN) #include "Engines/CoreAudio/CoreAudioAE.h" + #include "settings/SettingsManager.h" #else #include "Engines/SoftAE/SoftAE.h" #endif @@ -31,6 +33,10 @@ #include "Engines/PulseAE/PulseAE.h" #endif +#include "guilib/LocalizeStrings.h" +#include "settings/Setting.h" +#include "utils/StringUtils.h" + IAE* CAEFactory::AE = NULL; static float g_fVolume = 1.0f; static bool g_bMute = false; @@ -297,3 +303,58 @@ void CAEFactory::GarbageCollect() if(AE) AE->GarbageCollect(); } + +void CAEFactory::SettingOptionsAudioDevicesFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t) +{ + SettingOptionsAudioDevicesFillerGeneral(setting, list, current, false); +} + +void CAEFactory::SettingOptionsAudioDevicesPassthroughFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t) +{ + SettingOptionsAudioDevicesFillerGeneral(setting, list, current, true); +} + +void CAEFactory::SettingOptionsAudioOutputModesFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t) +{ + list.push_back(std::make_pair(g_localizeStrings.Get(338), AUDIO_ANALOG)); +#if !defined(TARGET_RASPBERRY_PI) + list.push_back(std::make_pair(g_localizeStrings.Get(339), AUDIO_IEC958)); +#endif + list.push_back(std::make_pair(g_localizeStrings.Get(420), AUDIO_HDMI)); +} + +void CAEFactory::SettingOptionsAudioDevicesFillerGeneral(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t, bool passthrough) +{ + current = ((const CSettingString*)setting)->GetValue(); + std::string firstDevice; + + bool foundValue = false; + AEDeviceList sinkList; + EnumerateOutputDevices(sinkList, passthrough); +#if !defined(TARGET_DARWIN) + if (sinkList.size() == 0) + list.push_back(std::make_pair("Error - no devices found", "error")); + else + { +#endif + for (AEDeviceList::const_iterator sink = sinkList.begin(); sink != sinkList.end(); sink++) + { + if (sink == sinkList.begin()) + firstDevice = sink->second; + +#if defined(TARGET_DARWIN) + list.push_back(StringSettingOption(sink->first, sink->first)); +#else + list.push_back(std::make_pair(sink->first, sink->second)); +#endif + + if (StringUtils::EqualsNoCase(current, sink->second)) + foundValue = true; + } +#if !defined(TARGET_DARWIN) + } +#endif + + if (!foundValue) + current = firstDevice; +} diff --git a/xbmc/cores/AudioEngine/AEFactory.h b/xbmc/cores/AudioEngine/AEFactory.h index 99cdebd10c354..56a1e273f3f60 100644 --- a/xbmc/cores/AudioEngine/AEFactory.h +++ b/xbmc/cores/AudioEngine/AEFactory.h @@ -19,9 +19,13 @@ * */ +#include + #include "Interfaces/AE.h" #include "threads/Thread.h" +class CSetting; + enum AEEngine { AE_ENGINE_NULL, @@ -58,8 +62,15 @@ class CAEFactory unsigned int encodedSampleRate, CAEChannelInfo channelLayout, unsigned int options = 0); static IAEStream *FreeStream(IAEStream *stream); static void GarbageCollect(); + + static void SettingOptionsAudioDevicesFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t); + static void SettingOptionsAudioDevicesPassthroughFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t); + static void SettingOptionsAudioOutputModesFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t); + private: static bool LoadEngine(enum AEEngine engine); static IAE *AE; + + static void SettingOptionsAudioDevicesFillerGeneral(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t, bool passthrough); }; diff --git a/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp b/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp index 34ddda64eb4cd..05b2bdaa12e6d 100644 --- a/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp +++ b/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp @@ -25,7 +25,7 @@ #include "cores/AudioEngine/Utils/AEUtil.h" #include "utils/log.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include CAEEncoderFFmpeg::CAEEncoderFFmpeg(): @@ -100,12 +100,12 @@ bool CAEEncoderFFmpeg::Initialize(AEAudioFormat &format) m_dllAvCodec.avcodec_register_all(); - bool ac3 = g_guiSettings.GetBool("audiooutput.ac3passthrough"); + bool ac3 = CSettings::Get().GetBool("audiooutput.ac3passthrough"); AVCodec *codec = NULL; #if 0 /* the DCA encoder is currently useless for transcode, it creates a 196 kHz DTS-HD like mongrel which is useless for SPDIF */ - bool dts = g_guiSettings.GetBool("audiooutput.dtspassthrough"); + bool dts = CSettings::Get().GetBool("audiooutput.dtspassthrough"); if (dts && (!ac3 || g_advancedSettings.m_audioTranscodeTo.Equals("dts"))) { m_CodecName = "DTS"; diff --git a/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAE.cpp b/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAE.cpp index 6435c87a27ef7..3aadf3b14e2f1 100644 --- a/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAE.cpp +++ b/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAE.cpp @@ -26,8 +26,8 @@ #include "CoreAudioAESound.h" #include "Application.h" #include "cores/AudioEngine/Utils/AEUtil.h" -#include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" +#include "settings/Settings.h" #include "threads/SingleLock.h" #include "utils/EndianSwap.h" #include "utils/log.h" @@ -214,12 +214,12 @@ bool CCoreAudioAE::OpenCoreAudio(unsigned int sampleRate, bool forceRaw, if (m_rawPassthrough) CLog::Log(LOGINFO, "CCoreAudioAE::OpenCoreAudio - RAW passthrough enabled"); - std::string m_outputDevice = g_guiSettings.GetString("audiooutput.audiodevice"); + std::string m_outputDevice = CSettings::Get().GetString("audiooutput.audiodevice"); // on iOS devices we set fixed to two channels. m_stdChLayout = AE_CH_LAYOUT_2_0; #if defined(TARGET_DARWIN_OSX) - switch (g_guiSettings.GetInt("audiooutput.channels")) + switch (CSettings::Get().GetInt("audiooutput.channels")) { default: case 0: m_stdChLayout = AE_CH_LAYOUT_2_0; break; /* do not allow 1_0 output */ @@ -236,7 +236,7 @@ bool CCoreAudioAE::OpenCoreAudio(unsigned int sampleRate, bool forceRaw, } #endif // force optical/coax to 2.0 output channels - if (!m_rawPassthrough && g_guiSettings.GetInt("audiooutput.mode") == AUDIO_IEC958) + if (!m_rawPassthrough && CSettings::Get().GetInt("audiooutput.mode") == AUDIO_IEC958) m_stdChLayout = AE_CH_LAYOUT_2_0; // setup the desired format diff --git a/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAEHALOSX.cpp b/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAEHALOSX.cpp index b43732f43e51e..52b2272a2d6f2 100644 --- a/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAEHALOSX.cpp +++ b/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAEHALOSX.cpp @@ -34,8 +34,8 @@ #include "CoreAudioChannelLayout.h" #include "cores/AudioEngine/Utils/AEUtil.h" -#include "settings/GUISettings.h" #include "utils/log.h" +#include "settings/Settings.h" CCoreAudioAEHALOSX::CCoreAudioAEHALOSX() : m_audioGraph (NULL ), @@ -93,9 +93,9 @@ bool CCoreAudioAEHALOSX::InitializePCM(ICoreAudioSource *pSource, AEAudioFormat if (!m_audioGraph) return false; - AudioChannelLayoutTag layout = g_LayoutMap[ g_guiSettings.GetInt("audiooutput.channels") ]; + AudioChannelLayoutTag layout = g_LayoutMap[ CSettings::Get().GetInt("audiooutput.channels") ]; // force optical/coax to 2.0 output channels - if (!m_Passthrough && g_guiSettings.GetInt("audiooutput.mode") == AUDIO_IEC958) + if (!m_Passthrough && CSettings::Get().GetInt("audiooutput.mode") == AUDIO_IEC958) layout = g_LayoutMap[1]; if (!m_audioGraph->Open(pSource, format, outputDevice, allowMixing, layout, m_initVolume )) diff --git a/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAEStream.cpp b/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAEStream.cpp index afd82852f96be..a9422f779d765 100644 --- a/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAEStream.cpp +++ b/xbmc/cores/AudioEngine/Engines/CoreAudio/CoreAudioAEStream.cpp @@ -26,7 +26,6 @@ #include "xbmc/cores/AudioEngine/Interfaces/AE.h" #include "xbmc/cores/AudioEngine/AEFactory.h" #include "xbmc/cores/AudioEngine/Utils/AEUtil.h" -#include "settings/GUISettings.h" #include "settings/Settings.h" #include "threads/SingleLock.h" #include "settings/AdvancedSettings.h" diff --git a/xbmc/cores/AudioEngine/Engines/PulseAE/PulseAE.cpp b/xbmc/cores/AudioEngine/Engines/PulseAE/PulseAE.cpp index dabe89160b3df..f5f699cb9deff 100644 --- a/xbmc/cores/AudioEngine/Engines/PulseAE/PulseAE.cpp +++ b/xbmc/cores/AudioEngine/Engines/PulseAE/PulseAE.cpp @@ -27,6 +27,7 @@ #include "Application.h" #include "threads/SingleLock.h" #include "utils/log.h" +#include "settings/Settings.h" #include #include #include "guilib/LocalizeStrings.h" diff --git a/xbmc/cores/AudioEngine/Engines/SoftAE/SoftAE.cpp b/xbmc/cores/AudioEngine/Engines/SoftAE/SoftAE.cpp index 9222944b36f95..d879fd72468e8 100644 --- a/xbmc/cores/AudioEngine/Engines/SoftAE/SoftAE.cpp +++ b/xbmc/cores/AudioEngine/Engines/SoftAE/SoftAE.cpp @@ -28,9 +28,8 @@ #include "utils/MathUtils.h" #include "utils/EndianSwap.h" #include "threads/SingleLock.h" -#include "settings/GUISettings.h" -#include "settings/Settings.h" #include "settings/AdvancedSettings.h" +#include "settings/Settings.h" #include "SoftAE.h" #include "SoftAESound.h" @@ -529,8 +528,7 @@ void CSoftAE::OnSettingsChange(const std::string& setting) setting == "audiooutput.passthroughaac" || setting == "audiooutput.truehdpassthrough" || setting == "audiooutput.dtshdpassthrough" || - setting == "audiooutput.channels" || - setting == "audiooutput.useexclusivemode" || + setting == "audiooutput.channels" || setting == "audiooutput.multichannellpcm" || setting == "audiooutput.stereoupmix") { @@ -552,13 +550,13 @@ void CSoftAE::LoadSettings() if (m_audiophile) CLog::Log(LOGINFO, "CSoftAE::LoadSettings - Audiophile switch enabled"); - m_stereoUpmix = g_guiSettings.GetBool("audiooutput.stereoupmix"); + m_stereoUpmix = CSettings::Get().GetBool("audiooutput.stereoupmix"); if (m_stereoUpmix) CLog::Log(LOGINFO, "CSoftAE::LoadSettings - Stereo upmix is enabled"); /* load the configuration */ m_stdChLayout = AE_CH_LAYOUT_2_0; - switch (g_guiSettings.GetInt("audiooutput.channels")) + switch (CSettings::Get().GetInt("audiooutput.channels")) { default: case 0: m_stdChLayout = AE_CH_LAYOUT_2_0; break; /* dont alow 1_0 output */ @@ -575,21 +573,21 @@ void CSoftAE::LoadSettings() } // force optical/coax to 2.0 output channels - if (!m_rawPassthrough && g_guiSettings.GetInt("audiooutput.mode") == AUDIO_IEC958) + if (!m_rawPassthrough && CSettings::Get().GetInt("audiooutput.mode") == AUDIO_IEC958) m_stdChLayout = AE_CH_LAYOUT_2_0; /* get the output devices and ensure they exist */ - m_device = g_guiSettings.GetString("audiooutput.audiodevice"); - m_passthroughDevice = g_guiSettings.GetString("audiooutput.passthroughdevice"); + m_device = CSettings::Get().GetString("audiooutput.audiodevice"); + m_passthroughDevice = CSettings::Get().GetString("audiooutput.passthroughdevice"); VerifySoundDevice(m_device , false); VerifySoundDevice(m_passthroughDevice, true ); m_transcode = ( - g_guiSettings.GetBool("audiooutput.ac3passthrough") /*|| - g_guiSettings.GetBool("audiooutput.dtspassthrough") */ + CSettings::Get().GetBool("audiooutput.ac3passthrough") /*|| + CSettings::Get().GetBool("audiooutput.dtspassthrough") */ ) && ( - (g_guiSettings.GetInt("audiooutput.mode") == AUDIO_IEC958) || - (g_guiSettings.GetInt("audiooutput.mode") == AUDIO_HDMI && !g_guiSettings.GetBool("audiooutput.multichannellpcm")) + (CSettings::Get().GetInt("audiooutput.mode") == AUDIO_IEC958) || + (CSettings::Get().GetInt("audiooutput.mode") == AUDIO_HDMI && !CSettings::Get().GetBool("audiooutput.multichannellpcm")) ); } diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp b/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp index 2629c72cec7da..10a6a6aa62975 100644 --- a/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp +++ b/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp @@ -32,7 +32,6 @@ #include "utils/log.h" #include "utils/MathUtils.h" #include "threads/SingleLock.h" -#include "settings/GUISettings.h" #if defined(HAS_AMLPLAYER) #include "cores/amlplayer/AMLUtils.h" #endif diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkProfiler.cpp b/xbmc/cores/AudioEngine/Sinks/AESinkProfiler.cpp index 3ccb83b3eed22..7c01573c95cf8 100644 --- a/xbmc/cores/AudioEngine/Sinks/AESinkProfiler.cpp +++ b/xbmc/cores/AudioEngine/Sinks/AESinkProfiler.cpp @@ -28,7 +28,6 @@ #include "utils/StdString.h" #include "utils/log.h" #include "utils/TimeUtils.h" -#include "settings/GUISettings.h" CAESinkProfiler::CAESinkProfiler() { diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp b/xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp index 8f82cec31bc87..ab197a7a2c2ba 100644 --- a/xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp +++ b/xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp @@ -26,7 +26,6 @@ #include #include "../Utils/AEUtil.h" -#include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" #include "utils/StdString.h" #include "utils/log.h" diff --git a/xbmc/cores/AudioEngine/Utils/AERemap.cpp b/xbmc/cores/AudioEngine/Utils/AERemap.cpp index 0ec257b17d6a0..f99d52eeac8b4 100644 --- a/xbmc/cores/AudioEngine/Utils/AERemap.cpp +++ b/xbmc/cores/AudioEngine/Utils/AERemap.cpp @@ -24,7 +24,7 @@ #include "cores/AudioEngine/AEFactory.h" #include "cores/AudioEngine/Utils/AEUtil.h" #include "utils/log.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" using namespace std; @@ -197,7 +197,7 @@ bool CAERemap::Initialize(CAEChannelInfo input, CAEChannelInfo output, bool fina #undef RM - if (g_guiSettings.GetBool("audiooutput.stereoupmix")) + if (CSettings::Get().GetBool("audiooutput.stereoupmix")) BuildUpmixMatrix(input, output); /* normalize the values */ @@ -207,7 +207,7 @@ bool CAERemap::Initialize(CAEChannelInfo input, CAEChannelInfo output, bool fina else { //FIXME: guisetting is reversed, change the setting name after frodo - normalize = !g_guiSettings.GetBool("audiooutput.normalizelevels"); + normalize = !CSettings::Get().GetBool("audiooutput.normalizelevels"); CLog::Log(LOGDEBUG, "AERemap: Downmix normalization is %s", (normalize ? "enabled" : "disabled")); } diff --git a/xbmc/cores/AudioEngine/Utils/AEUtil.h b/xbmc/cores/AudioEngine/Utils/AEUtil.h index 458dc00e39669..48cbc3b4a7239 100644 --- a/xbmc/cores/AudioEngine/Utils/AEUtil.h +++ b/xbmc/cores/AudioEngine/Utils/AEUtil.h @@ -42,6 +42,23 @@ #define MEMALIGN(b, x) __declspec(align(b)) x #endif +#define AUDIO_IS_BITSTREAM(x) ((x) == AUDIO_IEC958 || (x) == AUDIO_HDMI) + +enum AudioOutputs +{ + AUDIO_ANALOG = 0, + AUDIO_IEC958, + AUDIO_HDMI +}; + +// AV sync options +enum AVSync +{ + SYNC_DISCON = 0, + SYNC_SKIPDUP, + SYNC_RESAMPLE +}; + class CAEUtil { private: diff --git a/xbmc/cores/DllLoader/exports/emu_msvcrt.cpp b/xbmc/cores/DllLoader/exports/emu_msvcrt.cpp index 2f15c971d4283..d58ba7857a494 100644 --- a/xbmc/cores/DllLoader/exports/emu_msvcrt.cpp +++ b/xbmc/cores/DllLoader/exports/emu_msvcrt.cpp @@ -56,7 +56,7 @@ #include "filesystem/SpecialProtocol.h" #include "URL.h" #include "filesystem/File.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "FileItem.h" #include "filesystem/Directory.h" @@ -200,21 +200,21 @@ extern "C" void __stdcall init_emu_environ() extern "C" void __stdcall update_emu_environ() { // Use a proxy, if the GUI was configured as such - if (g_guiSettings.GetBool("network.usehttpproxy") - && !g_guiSettings.GetString("network.httpproxyserver").empty() - && !g_guiSettings.GetString("network.httpproxyport").empty() - && g_guiSettings.GetInt("network.httpproxytype") == 0) + if (CSettings::Get().GetBool("network.usehttpproxy") + && !CSettings::Get().GetString("network.httpproxyserver").empty() + && !CSettings::Get().GetString("network.httpproxyport").empty() + && CSettings::Get().GetInt("network.httpproxytype") == 0) { CStdString strProxy; - if (g_guiSettings.GetString("network.httpproxyusername") && - g_guiSettings.GetString("network.httpproxypassword")) + if (!CSettings::Get().GetString("network.httpproxyusername").empty() && + !CSettings::Get().GetString("network.httpproxypassword").empty()) { - strProxy.Format("%s:%s@", g_guiSettings.GetString("network.httpproxyusername").c_str(), - g_guiSettings.GetString("network.httpproxypassword").c_str()); + strProxy.Format("%s:%s@", CSettings::Get().GetString("network.httpproxyusername").c_str(), + CSettings::Get().GetString("network.httpproxypassword").c_str()); } - strProxy += g_guiSettings.GetString("network.httpproxyserver"); - strProxy += ":" + g_guiSettings.GetString("network.httpproxyport"); + strProxy += CSettings::Get().GetString("network.httpproxyserver"); + strProxy += ":" + CSettings::Get().GetString("network.httpproxyport"); #ifdef _WIN32 pgwin32_putenv(("HTTP_PROXY=http://" +strProxy).c_str()); diff --git a/xbmc/cores/VideoRenderers/BaseRenderer.cpp b/xbmc/cores/VideoRenderers/BaseRenderer.cpp index 513cf4818cb49..21842005005c6 100644 --- a/xbmc/cores/VideoRenderers/BaseRenderer.cpp +++ b/xbmc/cores/VideoRenderers/BaseRenderer.cpp @@ -23,13 +23,14 @@ #include #include "BaseRenderer.h" #include "settings/DisplaySettings.h" -#include "settings/Settings.h" -#include "settings/GUISettings.h" #include "settings/MediaSettings.h" +#include "settings/Settings.h" #include "guilib/GraphicContext.h" #include "guilib/GUIWindowManager.h" +#include "guilib/LocalizeStrings.h" #include "utils/log.h" #include "utils/MathUtils.h" +#include "utils/SystemInfo.h" #include "settings/AdvancedSettings.h" #include "cores/VideoRenderers/RenderFlags.h" @@ -74,7 +75,7 @@ void CBaseRenderer::ChooseBestResolution(float fps) // Adjust refreshrate to match source fps #if !defined(TARGET_DARWIN_IOS) - if (g_guiSettings.GetInt("videoplayer.adjustrefreshrate") != ADJUST_REFRESHRATE_OFF) + if (CSettings::Get().GetInt("videoplayer.adjustrefreshrate") != ADJUST_REFRESHRATE_OFF) { float weight; if (!FindResolutionFromOverride(fps, weight, false)) //find a refreshrate from overrides @@ -427,7 +428,7 @@ void CBaseRenderer::CalcNormalDisplayRect(float offsetX, float offsetY, float sc // allow a certain error to maximize screen size float fCorrection = screenWidth / screenHeight / outputFrameRatio - 1.0f; - float fAllowed = g_guiSettings.GetInt("videoplayer.errorinaspect") * 0.01f; + float fAllowed = CSettings::Get().GetInt("videoplayer.errorinaspect") * 0.01f; if(fCorrection > fAllowed) fCorrection = fAllowed; if(fCorrection < - fAllowed) fCorrection = - fAllowed; @@ -611,7 +612,7 @@ void CBaseRenderer::SetViewMode(int viewMode) CDisplaySettings::Get().SetNonLinearStretched(false); if ( CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode == ViewModeZoom || - (is43 && g_guiSettings.GetInt("videoplayer.stretch43") == ViewModeZoom)) + (is43 && CSettings::Get().GetInt("videoplayer.stretch43") == ViewModeZoom)) { // zoom image so no black bars CDisplaySettings::Get().SetPixelRatio(1.0); // calculate the desired output ratio @@ -643,7 +644,7 @@ void CBaseRenderer::SetViewMode(int viewMode) } } else if ( CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode == ViewModeWideZoom || - (is43 && g_guiSettings.GetInt("videoplayer.stretch43") == ViewModeWideZoom)) + (is43 && CSettings::Get().GetInt("videoplayer.stretch43") == ViewModeWideZoom)) { // super zoom float stretchAmount = (screenWidth / screenHeight) * CDisplaySettings::Get().GetResolutionInfo(res).fPixelRatio / sourceFrameRatio; CDisplaySettings::Get().SetPixelRatio(pow(stretchAmount, float(2.0/3.0))); @@ -651,7 +652,7 @@ void CBaseRenderer::SetViewMode(int viewMode) CDisplaySettings::Get().SetNonLinearStretched(true); } else if ( CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode == ViewModeStretch16x9 || - (is43 && g_guiSettings.GetInt("videoplayer.stretch43") == ViewModeStretch16x9)) + (is43 && CSettings::Get().GetInt("videoplayer.stretch43") == ViewModeStretch16x9)) { // stretch image to 16:9 ratio CDisplaySettings::Get().SetZoomAmount(1.0); if (res == RES_PAL_4x3 || res == RES_PAL60_4x3 || res == RES_NTSC_4x3 || res == RES_HDTV_480p_4x3) @@ -704,3 +705,20 @@ void CBaseRenderer::MarkDirty() g_windowManager.MarkDirty(m_destRect); } +void CBaseRenderer::SettingOptionsRenderMethodsFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t) +{ + list.push_back(make_pair(g_localizeStrings.Get(13416), RENDER_METHOD_AUTO)); + +#ifdef HAS_DX + if (g_sysinfo.IsVistaOrHigher()) + list.push_back(make_pair(g_localizeStrings.Get(16319), RENDER_METHOD_DXVA)); + list.push_back(make_pair(g_localizeStrings.Get(13431), RENDER_METHOD_D3D_PS)); + list.push_back(make_pair(g_localizeStrings.Get(13419), RENDER_METHOD_SOFTWARE)); +#endif + +#ifdef HAS_GL + list.push_back(make_pair(g_localizeStrings.Get(13417), RENDER_METHOD_ARB)); + list.push_back(make_pair(g_localizeStrings.Get(13418), RENDER_METHOD_GLSL)); + list.push_back(make_pair(g_localizeStrings.Get(13419), RENDER_METHOD_SOFTWARE)); +#endif +} diff --git a/xbmc/cores/VideoRenderers/BaseRenderer.h b/xbmc/cores/VideoRenderers/BaseRenderer.h index 3e1944d2e95b6..90c2d3afa1474 100644 --- a/xbmc/cores/VideoRenderers/BaseRenderer.h +++ b/xbmc/cores/VideoRenderers/BaseRenderer.h @@ -20,6 +20,8 @@ * */ +#include + #include "guilib/Resolution.h" #include "guilib/Geometry.h" #include "RenderFormats.h" @@ -27,6 +29,8 @@ #define MAX_PLANES 3 #define MAX_FIELDS 3 +class CSetting; + typedef struct YV12Image { BYTE * plane[MAX_PLANES]; @@ -65,6 +69,18 @@ enum ERENDERFEATURE RENDERFEATURE_POSTPROCESS }; +// Render Methods +enum RenderMethods +{ + RENDER_METHOD_AUTO = 0, + RENDER_METHOD_ARB, + RENDER_METHOD_GLSL, + RENDER_METHOD_SOFTWARE, + RENDER_METHOD_D3D_PS, + RENDER_METHOD_DXVA, + RENDER_OVERLAYS = 99 // to retain compatibility +}; + typedef void (*RenderUpdateCallBackFn)(const void *ctx, const CRect &SrcRect, const CRect &DestRect); struct DVDVideoPicture; @@ -92,6 +108,8 @@ class CBaseRenderer virtual void RegisterRenderUpdateCallBack(const void *ctx, RenderUpdateCallBackFn fn); + static void SettingOptionsRenderMethodsFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t); + protected: void ChooseBestResolution(float fps); bool FindResolutionFromOverride(float fps, float& weight, bool fallback); diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp index 7d53d862b06fe..267dd40fc2c97 100644 --- a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp +++ b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp @@ -30,11 +30,10 @@ #include "LinuxRendererGL.h" #include "Application.h" -#include "settings/Settings.h" #include "settings/AdvancedSettings.h" #include "settings/DisplaySettings.h" -#include "settings/GUISettings.h" #include "settings/MediaSettings.h" +#include "settings/Settings.h" #include "VideoShaders/YUV2RGBShader.h" #include "VideoShaders/VideoFilterShader.h" #include "windowing/WindowingFactory.h" @@ -327,7 +326,7 @@ bool CLinuxRendererGL::Configure(unsigned int width, unsigned int height, unsign m_nonLinStretchGui = false; m_pixelRatio = 1.0; - m_pboSupported = glewIsSupported("GL_ARB_pixel_buffer_object") && g_guiSettings.GetBool("videoplayer.usepbo"); + m_pboSupported = glewIsSupported("GL_ARB_pixel_buffer_object") && CSettings::Get().GetBool("videoplayer.usepbo"); return true; } @@ -984,7 +983,7 @@ void CLinuxRendererGL::LoadShaders(int field) } else { - int requestedMethod = g_guiSettings.GetInt("videoplayer.rendermethod"); + int requestedMethod = CSettings::Get().GetInt("videoplayer.rendermethod"); CLog::Log(LOGDEBUG, "GL: Requested render method: %d", requestedMethod); if (m_pYUVShader) @@ -3204,7 +3203,7 @@ bool CLinuxRendererGL::Supports(ERENDERFEATURE feature) { if(feature == RENDERFEATURE_BRIGHTNESS) { - if ((m_renderMethod & RENDER_VDPAU) && !g_guiSettings.GetBool("videoscreen.limitedrange")) + if ((m_renderMethod & RENDER_VDPAU) && !CSettings::Get().GetBool("videoscreen.limitedrange")) return true; if (m_renderMethod & RENDER_VAAPI) @@ -3217,7 +3216,7 @@ bool CLinuxRendererGL::Supports(ERENDERFEATURE feature) if(feature == RENDERFEATURE_CONTRAST) { - if ((m_renderMethod & RENDER_VDPAU) && !g_guiSettings.GetBool("videoscreen.limitedrange")) + if ((m_renderMethod & RENDER_VDPAU) && !CSettings::Get().GetBool("videoscreen.limitedrange")) return true; if (m_renderMethod & RENDER_VAAPI) @@ -3361,7 +3360,7 @@ bool CLinuxRendererGL::Supports(ESCALINGMETHOD method) // if scaling is below level, avoid hq scaling float scaleX = fabs(((float)m_sourceWidth - m_destRect.Width())/m_sourceWidth)*100; float scaleY = fabs(((float)m_sourceHeight - m_destRect.Height())/m_sourceHeight)*100; - int minScale = g_guiSettings.GetInt("videoplayer.hqscalers"); + int minScale = CSettings::Get().GetInt("videoplayer.hqscalers"); if (scaleX < minScale && scaleY < minScale) return false; diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp b/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp index cca55c78b2333..402f338a8d4ae 100644 --- a/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp +++ b/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp @@ -32,11 +32,10 @@ #include "utils/fastmemcpy.h" #include "utils/MathUtils.h" #include "utils/GLUtils.h" -#include "settings/Settings.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" -#include "settings/MediaSettings.h" #include "settings/DisplaySettings.h" +#include "settings/MediaSettings.h" +#include "settings/Settings.h" #include "guilib/FrameBufferObject.h" #include "VideoShaders/YUV2RGBShader.h" #include "VideoShaders/VideoFilterShader.h" @@ -621,7 +620,7 @@ void CLinuxRendererGLES::LoadShaders(int field) #ifdef TARGET_DARWIN_IOS float ios_version = GetIOSVersion(); #endif - int requestedMethod = g_guiSettings.GetInt("videoplayer.rendermethod"); + int requestedMethod = CSettings::Get().GetInt("videoplayer.rendermethod"); CLog::Log(LOGDEBUG, "GL: Requested render method: %d", requestedMethod); if (m_pYUVShader) diff --git a/xbmc/cores/VideoRenderers/OverlayRenderer.cpp b/xbmc/cores/VideoRenderers/OverlayRenderer.cpp index 30267a2e5c8df..59a4732923329 100644 --- a/xbmc/cores/VideoRenderers/OverlayRenderer.cpp +++ b/xbmc/cores/VideoRenderers/OverlayRenderer.cpp @@ -26,11 +26,13 @@ #include "cores/dvdplayer/DVDCodecs/Overlay/DVDOverlaySpu.h" #include "cores/dvdplayer/DVDCodecs/Overlay/DVDOverlaySSA.h" #include "cores/VideoRenderers/RenderManager.h" +#include "guilib/GraphicContext.h" #include "Application.h" #include "guilib/GraphicContext.h" #include "windowing/WindowingFactory.h" #include "settings/DisplaySettings.h" #include "settings/Settings.h" +#include "settings/DisplaySettings.h" #include "threads/SingleLock.h" #include "utils/MathUtils.h" #if defined(HAS_GL) || defined(HAS_GLES) diff --git a/xbmc/cores/VideoRenderers/RenderCapture.cpp b/xbmc/cores/VideoRenderers/RenderCapture.cpp index 8b6b0b6bf2dfa..252dea995a890 100644 --- a/xbmc/cores/VideoRenderers/RenderCapture.cpp +++ b/xbmc/cores/VideoRenderers/RenderCapture.cpp @@ -22,8 +22,8 @@ #include "utils/log.h" #include "windowing/WindowingFactory.h" #include "utils/fastmemcpy.h" -#include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" +#include "settings/Settings.h" CRenderCaptureBase::CRenderCaptureBase() { @@ -94,7 +94,7 @@ void CRenderCaptureGL::BeginRender() if (!m_asyncChecked) { #ifndef HAS_GLES - bool usePbo = g_guiSettings.GetBool("videoplayer.usepbo"); + bool usePbo = CSettings::Get().GetBool("videoplayer.usepbo"); m_asyncSupported = g_Windowing.IsExtSupported("GL_ARB_pixel_buffer_object") && usePbo; m_occlusionQuerySupported = g_Windowing.IsExtSupported("GL_ARB_occlusion_query"); diff --git a/xbmc/cores/VideoRenderers/RenderManager.cpp b/xbmc/cores/VideoRenderers/RenderManager.cpp index 14c30843e84b5..61410a849a937 100644 --- a/xbmc/cores/VideoRenderers/RenderManager.cpp +++ b/xbmc/cores/VideoRenderers/RenderManager.cpp @@ -31,10 +31,9 @@ #include "Application.h" #include "ApplicationMessenger.h" -#include "settings/Settings.h" -#include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" #include "settings/MediaSettings.h" +#include "settings/Settings.h" #if defined(HAS_GL) #include "LinuxRendererGL.h" @@ -641,7 +640,7 @@ float CXBMCRenderManager::GetMaximumFPS() { float fps; - if (g_guiSettings.GetInt("videoscreen.vsync") != VSYNC_DISABLED) + if (CSettings::Get().GetInt("videoscreen.vsync") != VSYNC_DISABLED) { fps = (float)g_VideoReferenceClock.GetRefreshRate(); if (fps <= 0) fps = g_graphicsContext.GetFPS(); diff --git a/xbmc/cores/VideoRenderers/WinRenderer.cpp b/xbmc/cores/VideoRenderers/WinRenderer.cpp index 6ed53dcc4c2b9..0f38c9b476f4d 100644 --- a/xbmc/cores/VideoRenderers/WinRenderer.cpp +++ b/xbmc/cores/VideoRenderers/WinRenderer.cpp @@ -23,9 +23,8 @@ #include "WinRenderer.h" #include "Util.h" #include "settings/DisplaySettings.h" -#include "settings/Settings.h" -#include "settings/GUISettings.h" #include "settings/MediaSettings.h" +#include "settings/Settings.h" #include "guilib/Texture.h" #include "windowing/WindowingFactory.h" #include "settings/AdvancedSettings.h" @@ -382,7 +381,7 @@ unsigned int CWinRenderer::PreInit() g_Windowing.Get3DDevice()->GetDeviceCaps(&m_deviceCaps); - m_iRequestedMethod = g_guiSettings.GetInt("videoplayer.rendermethod"); + m_iRequestedMethod = CSettings::Get().GetInt("videoplayer.rendermethod"); if ((g_advancedSettings.m_DXVAForceProcessorRenderer || m_iRequestedMethod == RENDER_METHOD_DXVA) && !m_processor.PreInit()) CLog::Log(LOGNOTICE, "CWinRenderer::Preinit - could not init DXVA2 processor - skipping"); @@ -1085,7 +1084,7 @@ bool CWinRenderer::Supports(ESCALINGMETHOD method) // if scaling is below level, avoid hq scaling float scaleX = fabs(((float)m_sourceWidth - m_destRect.Width())/m_sourceWidth)*100; float scaleY = fabs(((float)m_sourceHeight - m_destRect.Height())/m_sourceHeight)*100; - int minScale = g_guiSettings.GetInt("videoplayer.hqscalers"); + int minScale = CSettings::Get().GetInt("videoplayer.hqscalers"); if (scaleX < minScale && scaleY < minScale) return false; return true; diff --git a/xbmc/cores/VideoRenderers/legacy/ComboRenderer.cpp b/xbmc/cores/VideoRenderers/legacy/ComboRenderer.cpp index eb6078be89e02..6cc8842b2e93e 100644 --- a/xbmc/cores/VideoRenderers/legacy/ComboRenderer.cpp +++ b/xbmc/cores/VideoRenderers/legacy/ComboRenderer.cpp @@ -21,7 +21,7 @@ #include "stdafx.h" #include "ComboRenderer.h" #include "Application.h" -#include "Settings.h" +#include "settings/Settings.h" #include "settings/DisplaySettings.h" CComboRenderer::CComboRenderer(LPDIRECT3DDEVICE8 pDevice) @@ -384,7 +384,7 @@ void CComboRenderer::CheckScreenSaver() if (g_application.IsInScreenSaver() && !m_bHasDimView) { D3DLOCKED_RECT lr; - float fAmount = (float)g_guiSettings.GetInt("screensaver.dimlevel") / 100.0f; + float fAmount = (float)CSettings::Get().GetInt("screensaver.dimlevel") / 100.0f; if ( D3D_OK == m_YUY2Texture[m_iYUY2RenderBuffer]->LockRect(0, &lr, NULL, 0 )) { // Drop brightness of current surface to 20% diff --git a/xbmc/cores/amlplayer/AMLPlayer.cpp b/xbmc/cores/amlplayer/AMLPlayer.cpp index 59917ab2997e5..de145d2e46ee6 100644 --- a/xbmc/cores/amlplayer/AMLPlayer.cpp +++ b/xbmc/cores/amlplayer/AMLPlayer.cpp @@ -37,9 +37,9 @@ #include "guilib/GUIWindowManager.h" #include "guilib/LocalizeStrings.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" -#include "settings/Settings.h" #include "settings/VideoSettings.h" +#include "settings/MediaSettings.h" +#include "settings/Settings.h" #include "threads/SingleLock.h" #include "utils/log.h" #include "utils/TimeUtils.h" @@ -575,8 +575,8 @@ bool CAMLPlayer::OpenFile(const CFileItem &file, const CPlayerOptions &options) m_audio_info = "none"; m_audio_delay = 0; - m_audio_passthrough_ac3 = g_guiSettings.GetBool("audiooutput.ac3passthrough"); - m_audio_passthrough_dts = g_guiSettings.GetBool("audiooutput.dtspassthrough"); + m_audio_passthrough_ac3 = CSettings::Get().GetBool("audiooutput.ac3passthrough"); + m_audio_passthrough_dts = CSettings::Get().GetBool("audiooutput.dtspassthrough"); m_video_info = "none"; m_video_width = 0; diff --git a/xbmc/cores/dvdplayer/DVDAudio.cpp b/xbmc/cores/dvdplayer/DVDAudio.cpp index 1b31ad161f4eb..dd8eab3e3f4bc 100644 --- a/xbmc/cores/dvdplayer/DVDAudio.cpp +++ b/xbmc/cores/dvdplayer/DVDAudio.cpp @@ -26,7 +26,6 @@ #include "DVDPlayerAudio.h" #include "cores/AudioEngine/AEFactory.h" #include "cores/AudioEngine/Interfaces/AEStream.h" -#include "settings/Settings.h" #include "settings/MediaSettings.h" using namespace std; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp index 147225797a84e..efae6eb375705 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp @@ -24,7 +24,11 @@ #endif #include "../../DVDStreamInfo.h" #include "utils/log.h" -#include "settings/GUISettings.h" + +#if defined(TARGET_DARWIN) +#include "settings/Settings.h" +#include "cores/AudioEngine/Utils/AEUtil.h" +#endif CDVDAudioCodecFFmpeg::CDVDAudioCodecFFmpeg() : CDVDAudioCodec() { @@ -72,9 +76,9 @@ bool CDVDAudioCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options } #if defined(TARGET_DARWIN) - int audioMode = g_guiSettings.GetInt("audiooutput.mode"); + int audioMode = CSettings::Get().GetInt("audiooutput.mode"); if (audioMode == AUDIO_HDMI) - m_bLpcmMode = g_guiSettings.GetBool("audiooutput.multichannellpcm"); + m_bLpcmMode = CSettings::Get().GetBool("audiooutput.multichannellpcm"); #endif m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec); diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthrough.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthrough.cpp index e6deb6cac77ce..9d7030f36b634 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthrough.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthrough.cpp @@ -21,7 +21,7 @@ #include "DVDAudioCodecPassthrough.h" #include "DVDCodecs/DVDCodecs.h" #include "DVDStreamInfo.h" -#include "settings/GUISettings.h" +#include "cores/AudioEngine/Utils/AEUtil.h" #include "settings/Settings.h" #include "utils/log.h" @@ -49,17 +49,17 @@ bool CDVDAudioCodecPassthrough::Open(CDVDStreamInfo &hints, CDVDCodecOptions &op bool bSupportsTrueHDOut = false; bool bSupportsDTSHDOut = false; - int audioMode = g_guiSettings.GetInt("audiooutput.mode"); + int audioMode = CSettings::Get().GetInt("audiooutput.mode"); if (AUDIO_IS_BITSTREAM(audioMode)) { - bSupportsAC3Out = g_guiSettings.GetBool("audiooutput.ac3passthrough"); - bSupportsDTSOut = g_guiSettings.GetBool("audiooutput.dtspassthrough"); + bSupportsAC3Out = CSettings::Get().GetBool("audiooutput.ac3passthrough"); + bSupportsDTSOut = CSettings::Get().GetBool("audiooutput.dtspassthrough"); } if (audioMode == AUDIO_HDMI) { - bSupportsTrueHDOut = g_guiSettings.GetBool("audiooutput.truehdpassthrough"); - bSupportsDTSHDOut = g_guiSettings.GetBool("audiooutput.dtshdpassthrough" ) && bSupportsDTSOut; + bSupportsTrueHDOut = CSettings::Get().GetBool("audiooutput.truehdpassthrough"); + bSupportsDTSHDOut = CSettings::Get().GetBool("audiooutput.dtshdpassthrough" ) && bSupportsDTSOut; } /* only get the dts core from the parser if we don't support dtsHD */ diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp index e9a820e63c8c1..4f607b5baf1f4 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp @@ -21,7 +21,7 @@ #include "DVDAudioCodecPassthroughFFmpeg.h" #include "DVDCodecs/DVDCodecs.h" #include "DVDStreamInfo.h" -#include "settings/GUISettings.h" +#include "cores/AudioEngine/Utils/AEUtil.h" #include "settings/MediaSettings.h" #include "settings/Settings.h" #include "utils/log.h" @@ -293,14 +293,14 @@ bool CDVDAudioCodecPassthroughFFmpeg::SupportsFormat(CDVDStreamInfo &hints) bool CDVDAudioCodecPassthroughFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options) { - int audioMode = g_guiSettings.GetInt("audiooutput.mode"); + int audioMode = CSettings::Get().GetInt("audiooutput.mode"); // TODO - move this stuff somewhere else if (AUDIO_IS_BITSTREAM(audioMode)) { - m_bSupportsAC3Out = g_guiSettings.GetBool("audiooutput.ac3passthrough"); - m_bSupportsDTSOut = g_guiSettings.GetBool("audiooutput.dtspassthrough"); - m_bSupportsAACOut = g_guiSettings.GetBool("audiooutput.passthroughaac"); + m_bSupportsAC3Out = CSettings::Get().GetBool("audiooutput.ac3passthrough"); + m_bSupportsDTSOut = CSettings::Get().GetBool("audiooutput.dtspassthrough"); + m_bSupportsAACOut = CSettings::Get().GetBool("audiooutput.passthroughaac"); } else return false; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp b/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp index 4ea66172f52f9..03429b5d18b38 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp @@ -53,7 +53,7 @@ #include "DVDStreamInfo.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/SystemInfo.h" CDVDVideoCodec* CDVDFactoryCodec::OpenCodec(CDVDVideoCodec* pCodec, CDVDStreamInfo &hints, CDVDCodecOptions &options ) @@ -180,7 +180,7 @@ CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, unsigne if( (pCodec = OpenCodec(new CDVDVideoCodecLibMpeg2(), hint, options)) ) return pCodec; } #if defined(HAVE_LIBVDADECODER) - if (!hint.software && g_guiSettings.GetBool("videoplayer.usevda")) + if (!hint.software && CSettings::Get().GetBool("videoplayer.usevda")) { if (g_sysinfo.HasVDADecoder()) { @@ -193,7 +193,7 @@ CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, unsigne #endif #if defined(HAVE_VIDEOTOOLBOXDECODER) - if (!hint.software && g_guiSettings.GetBool("videoplayer.usevideotoolbox")) + if (!hint.software && CSettings::Get().GetBool("videoplayer.usevideotoolbox")) { if (g_sysinfo.HasVideoToolBoxDecoder()) { @@ -212,7 +212,7 @@ CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, unsigne #endif #if defined(HAVE_LIBCRYSTALHD) - if (!hint.software && g_guiSettings.GetBool("videoplayer.usechd")) + if (!hint.software && CSettings::Get().GetBool("videoplayer.usechd")) { if (CCrystalHD::GetInstance()->DevicePresent()) { @@ -236,7 +236,7 @@ CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, unsigne #endif #if defined(HAVE_LIBOPENMAX) - if (g_guiSettings.GetBool("videoplayer.useomx") && !hint.software ) + if (CSettings::Get().GetBool("videoplayer.useomx") && !hint.software ) { if (hint.codec == CODEC_ID_H264 || hint.codec == CODEC_ID_MPEG2VIDEO || hint.codec == CODEC_ID_VC1) { diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecTX3G.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecTX3G.cpp index c269bf7e21ddb..477c74633c913 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecTX3G.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecTX3G.cpp @@ -24,7 +24,7 @@ #include "DVDOverlayText.h" #include "DVDStreamInfo.h" #include "DVDCodecs/DVDCodecs.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/log.h" // 3GPP/TX3G (aka MPEG-4 Timed Text) Subtitle support @@ -64,7 +64,7 @@ CDVDOverlayCodecTX3G::CDVDOverlayCodecTX3G() : CDVDOverlayCodec("TX3G Subtitle D m_pOverlay = NULL; // stupid, this comes from a static global in GUIWindowFullScreen.cpp uint32_t colormap[8] = { 0xFFFFFF00, 0xFFFFFFFF, 0xFF0099FF, 0xFF00FF00, 0xFFCCFF00, 0xFF00FFFF, 0xFFE5E5E5, 0xFFC0C0C0 }; - m_textColor = colormap[g_guiSettings.GetInt("subtitles.color")]; + m_textColor = colormap[CSettings::Get().GetInt("subtitles.color")]; } CDVDOverlayCodecTX3G::~CDVDOverlayCodecTX3G() diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecCrystalHD.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecCrystalHD.cpp index c5e1fbabcad53..74fd066cb4bef 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecCrystalHD.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecCrystalHD.cpp @@ -26,10 +26,10 @@ #endif #if defined(HAVE_LIBCRYSTALHD) -#include "settings/GUISettings.h" #include "DVDClock.h" #include "DVDStreamInfo.h" #include "DVDVideoCodecCrystalHD.h" +#include "settings/Settings.h" #include "utils/log.h" #include "utils/TimeUtils.h" @@ -51,7 +51,7 @@ CDVDVideoCodecCrystalHD::~CDVDVideoCodecCrystalHD() bool CDVDVideoCodecCrystalHD::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options) { - if (g_guiSettings.GetBool("videoplayer.usechd") && !hints.software) + if (CSettings::Get().GetBool("videoplayer.usechd") && !hints.software) { switch (hints.codec) { diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp index 633172292be95..eb45f9ad9a7fd 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp @@ -33,7 +33,7 @@ #include "utils/CPUInfo.h" #endif #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/log.h" #include "boost/shared_ptr.hpp" #include "threads/Atomics.h" @@ -72,7 +72,7 @@ enum PixelFormat CDVDVideoCodecFFmpeg::GetFormat( struct AVCodecContext * avctx while(*cur != PIX_FMT_NONE) { #ifdef HAVE_LIBVDPAU - if(CVDPAU::IsVDPAUFormat(*cur) && g_guiSettings.GetBool("videoplayer.usevdpau")) + if(CVDPAU::IsVDPAUFormat(*cur) && CSettings::Get().GetBool("videoplayer.usevdpau")) { if(ctx->GetHardware()) return *cur; @@ -89,7 +89,7 @@ enum PixelFormat CDVDVideoCodecFFmpeg::GetFormat( struct AVCodecContext * avctx } #endif #ifdef HAS_DX - if(DXVA::CDecoder::Supports(*cur) && g_guiSettings.GetBool("videoplayer.usedxva2")) + if(DXVA::CDecoder::Supports(*cur) && CSettings::Get().GetBool("videoplayer.usedxva2")) { DXVA::CDecoder* dec = new DXVA::CDecoder(); if(dec->Open(avctx, *cur, ctx->m_uSurfacesCount)) @@ -103,7 +103,7 @@ enum PixelFormat CDVDVideoCodecFFmpeg::GetFormat( struct AVCodecContext * avctx #endif #ifdef HAVE_LIBVA // mpeg4 vaapi decoding is disabled - if(*cur == PIX_FMT_VAAPI_VLD && g_guiSettings.GetBool("videoplayer.usevaapi") + if(*cur == PIX_FMT_VAAPI_VLD && CSettings::Get().GetBool("videoplayer.usevaapi") && (avctx->codec_id != CODEC_ID_MPEG4 || g_advancedSettings.m_videoAllowMpeg4VAAPI)) { if (ctx->GetHardware() != NULL) @@ -204,7 +204,7 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options } #ifdef HAVE_LIBVDPAU - if(g_guiSettings.GetBool("videoplayer.usevdpau") && !m_bSoftware) + if(CSettings::Get().GetBool("videoplayer.usevdpau") && !m_bSoftware) { while((pCodec = m_dllAvCodec.av_codec_next(pCodec))) { diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecOpenMax.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecOpenMax.cpp index fdd947227e130..3eb722c90f597 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecOpenMax.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecOpenMax.cpp @@ -26,7 +26,6 @@ #if defined(HAVE_LIBOPENMAX) #include "DVDClock.h" -#include "settings/GUISettings.h" #include "DVDStreamInfo.h" #include "DVDVideoCodecOpenMax.h" #include "OpenMaxVideo.h" @@ -52,7 +51,7 @@ CDVDVideoCodecOpenMax::~CDVDVideoCodecOpenMax() bool CDVDVideoCodecOpenMax::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options) { // we always qualify even if DVDFactoryCodec does this too. - if (g_guiSettings.GetBool("videoplayer.useomx") && !hints.software) + if (CSettings::Get().GetBool("videoplayer.useomx") && !hints.software) { m_convert_bitstream = false; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.cpp index e41ea34d651c2..bb5e23af8cb4e 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.cpp @@ -29,11 +29,11 @@ #include "DVDStreamInfo.h" #include "cores/dvdplayer/DVDCodecs/DVDCodecUtils.h" #include "osx/CocoaInterface.h" -#include "settings/GUISettings.h" #include "windowing/WindowingFactory.h" #include "utils/BitstreamConverter.h" #include "utils/log.h" #include "utils/TimeUtils.h" +#include "settings/Settings.h" #include @@ -236,7 +236,7 @@ bool CDVDVideoCodecVDA::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options) else m_dll = g_DllLibVDADecoder; - if (g_guiSettings.GetBool("videoplayer.usevda") && !hints.software) + if (CSettings::Get().GetBool("videoplayer.usevda") && !hints.software) { CCocoaAutoPool pool; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp index bba603dd7342a..905a355f2a06b 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp @@ -23,13 +23,13 @@ #endif #if defined(HAVE_VIDEOTOOLBOXDECODER) -#include "GUISettings.h" #include "DVDClock.h" #include "DVDStreamInfo.h" #include "DVDCodecUtils.h" #include "DVDVideoCodecVideoToolBox.h" #include "lib/DllSwScale.h" #include "lib/DllAvFormat.h" +#include "settings/Settings.h" #include "utils/log.h" #include "utils/TimeUtils.h" #include "osx/DarwinUtils.h" @@ -1058,7 +1058,7 @@ CDVDVideoCodecVideoToolBox::~CDVDVideoCodecVideoToolBox() bool CDVDVideoCodecVideoToolBox::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options) { - if (g_guiSettings.GetBool("videoplayer.usevideotoolbox") && !hints.software) + if (CSettings::Get().GetBool("videoplayer.usevideotoolbox") && !hints.software) { m_dllAvUtil = new DllAvUtil; m_dllAvFormat = new DllAvFormat; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DXVA.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DXVA.cpp index 147d954a660d2..e1a3dd476f005 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DXVA.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DXVA.cpp @@ -36,6 +36,7 @@ #include "windowing/WindowingFactory.h" #include "../../../VideoRenderers/WinRenderer.h" #include "settings/Settings.h" +#include "settings/MediaSettings.h" #include "boost/shared_ptr.hpp" #include "utils/AutoPtrHandle.h" #include "settings/AdvancedSettings.h" diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp index a781585984e40..9cf27be17d52c 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp @@ -29,7 +29,6 @@ #include "DVDVideoCodecFFmpeg.h" #include "DVDClock.h" #include "settings/Settings.h" -#include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" #include "settings/MediaSettings.h" #include "Application.h" @@ -617,7 +616,7 @@ void CVDPAU::SetColor() vdp_st = vdp_generate_csc_matrix(&m_Procamp, VDP_COLOR_STANDARD_ITUR_BT_601, &m_CSCMatrix); VdpVideoMixerAttribute attributes[] = { VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX }; - if (g_guiSettings.GetBool("videoscreen.limitedrange")) + if (CSettings::Get().GetBool("videoscreen.limitedrange")) { void const * pm_CSCMatix[] = { &studioCSC }; vdp_st = vdp_video_mixer_set_attribute_values(videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix); diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp index 1257052f88953..f95b0081757e7 100644 --- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp +++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp @@ -40,7 +40,7 @@ #include "DVDClock.h" // for DVD_TIME_BASE #include "commons/Exception.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "filesystem/File.h" #include "filesystem/Directory.h" #include "utils/log.h" @@ -1033,7 +1033,7 @@ void CDVDDemuxFFmpeg::AddStream(int iId) } case AVMEDIA_TYPE_SUBTITLE: { - if (pStream->codec->codec_id == CODEC_ID_DVB_TELETEXT && g_guiSettings.GetBool("videoplayer.teletextenabled")) + if (pStream->codec->codec_id == CODEC_ID_DVB_TELETEXT && CSettings::Get().GetBool("videoplayer.teletextenabled")) { CDemuxStreamTeletext* st = new CDemuxStreamTeletext(); m_streams[iId] = st; diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.cpp b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.cpp index 58b29688fd173..7352aa10aae98 100644 --- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.cpp +++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.cpp @@ -24,7 +24,7 @@ #include "IDVDPlayer.h" #include "DVDCodecs/Overlay/DVDOverlay.h" #include "DVDCodecs/Overlay/DVDOverlayImage.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "LangInfo.h" #include "utils/log.h" #include "utils/URIUtils.h" @@ -380,7 +380,7 @@ bool CDVDInputStreamBluray::Open(const char* strFile, const std::string& content if(m_navmode) { - int region = g_guiSettings.GetInt("dvds.playerregion"); + int region = CSettings::Get().GetInt("dvds.playerregion"); if(region == 0) { CLog::Log(LOGWARNING, "CDVDInputStreamBluray::Open - region dvd must be set in setting, assuming region 1"); diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp index 67daf84767f89..eba4b0df365d5 100644 --- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp +++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp @@ -22,7 +22,7 @@ #include "utils/LangCodeExpander.h" #include "../DVDDemuxSPU.h" #include "DVDStateSerializer.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "LangInfo.h" #include "utils/log.h" #include "guilib/Geometry.h" @@ -104,7 +104,7 @@ bool CDVDInputStreamNavigator::Open(const char* strFile, const std::string& cont return false; } - int region = g_guiSettings.GetInt("dvds.playerregion"); + int region = CSettings::Get().GetInt("dvds.playerregion"); int mask = 0; if(region > 0) mask = 1 << (region-1); @@ -179,7 +179,7 @@ bool CDVDInputStreamNavigator::Open(const char* strFile, const std::string& cont } // jump directly to title menu - if(g_guiSettings.GetBool("dvds.automenu")) + if(CSettings::Get().GetBool("dvds.automenu")) { int len, event; uint8_t buf[2048]; diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamPVRManager.cpp b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamPVRManager.cpp index 431c280a5e82b..aa3298b953a2f 100644 --- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamPVRManager.cpp +++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamPVRManager.cpp @@ -28,7 +28,7 @@ #include "utils/StringUtils.h" #include "pvr/addons/PVRClients.h" #include "pvr/channels/PVRChannelGroupsContainer.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" using namespace XFILE; using namespace PVR; @@ -131,7 +131,7 @@ bool CDVDInputStreamPVRManager::Open(const char* strFile, const std::string& con } } - ResetScanTimeout((unsigned int) g_guiSettings.GetInt("pvrplayback.scantime") * 1000); + ResetScanTimeout((unsigned int) CSettings::Get().GetInt("pvrplayback.scantime") * 1000); m_content = content; CLog::Log(LOGDEBUG, "CDVDInputStreamPVRManager::Open - stream opened: %s", transFile.c_str()); diff --git a/xbmc/cores/dvdplayer/DVDPlayer.cpp b/xbmc/cores/dvdplayer/DVDPlayer.cpp index fdd5185562035..3080827ebe5f3 100644 --- a/xbmc/cores/dvdplayer/DVDPlayer.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayer.cpp @@ -63,10 +63,9 @@ #endif #include "settings/AdvancedSettings.h" #include "FileItem.h" -#include "settings/GUISettings.h" -#include "settings/MediaSettings.h" #include "GUIUserMessages.h" #include "settings/Settings.h" +#include "settings/MediaSettings.h" #include "utils/log.h" #include "utils/TimeUtils.h" #include "utils/StreamDetails.h" @@ -142,7 +141,7 @@ static bool PredicateAudioPriority(const SelectionStream& lh, const SelectionStr 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")) + if(!StringUtils::EqualsNoCase(CSettings::Get().GetString("locale.audiolanguage"), "original")) { CStdString audio_language = g_langInfo.GetAudioLanguage(); PREDICATE_RETURN(audio_language.Equals(lh.language.c_str()) @@ -172,7 +171,7 @@ static bool PredicateSubtitlePriority(const SelectionStream& lh, const Selection , rh.type_index == CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream); CStdString subtitle_language = g_langInfo.GetSubtitleLanguage(); - if(!g_guiSettings.GetString("locale.subtitlelanguage").Equals("original")) + if(!StringUtils::EqualsNoCase(CSettings::Get().GetString("locale.subtitlelanguage"), "original")) { PREDICATE_RETURN((lh.source == STREAM_SOURCE_DEMUX_SUB || lh.source == STREAM_SOURCE_TEXT) && subtitle_language.Equals(lh.language.c_str()) , (rh.source == STREAM_SOURCE_DEMUX_SUB || rh.source == STREAM_SOURCE_TEXT) && subtitle_language.Equals(rh.language.c_str())); @@ -184,7 +183,7 @@ static bool PredicateSubtitlePriority(const SelectionStream& lh, const Selection PREDICATE_RETURN(lh.source == STREAM_SOURCE_TEXT , rh.source == STREAM_SOURCE_TEXT); - if(!g_guiSettings.GetString("locale.subtitlelanguage").Equals("original")) + if(!StringUtils::EqualsNoCase(CSettings::Get().GetString("locale.subtitlelanguage"), "original")) { PREDICATE_RETURN(subtitle_language.Equals(lh.language.c_str()) , subtitle_language.Equals(rh.language.c_str())); @@ -583,7 +582,7 @@ bool CDVDPlayer::OpenInputStream() if (filename.Left(7) == "http://" && CURL(filename).GetFileName().Right(5) == ".m3u8") { // get the available bandwidth (as per user settings) - int maxrate = g_guiSettings.GetInt("network.bandwidth"); + int maxrate = CSettings::Get().GetInt("network.bandwidth"); if(maxrate <= 0) maxrate = INT_MAX; @@ -2274,7 +2273,7 @@ void CDVDPlayer::HandleMessages() if(input) { bool bSwitchSuccessful(false); - bool bShowPreview(g_guiSettings.GetInt("pvrplayback.channelentrytimeout") > 0); + bool bShowPreview(CSettings::Get().GetInt("pvrplayback.channelentrytimeout") > 0); if (!bShowPreview) { @@ -2292,7 +2291,7 @@ void CDVDPlayer::HandleMessages() if (bShowPreview) { UpdateApplication(0); - m_iChannelEntryTimeOut = XbmcThreads::SystemClockMillis() + g_guiSettings.GetInt("pvrplayback.channelentrytimeout"); + m_iChannelEntryTimeOut = XbmcThreads::SystemClockMillis() + CSettings::Get().GetInt("pvrplayback.channelentrytimeout"); } else { @@ -2375,7 +2374,7 @@ void CDVDPlayer::SetCaching(ECacheState state) m_dvdPlayerVideo.SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1); if (state == CACHESTATE_PVR) - m_pInputStream->ResetScanTimeout((unsigned int) g_guiSettings.GetInt("pvrplayback.scantime") * 1000); + m_pInputStream->ResetScanTimeout((unsigned int) CSettings::Get().GetInt("pvrplayback.scantime") * 1000); } if(state == CACHESTATE_PLAY @@ -3451,9 +3450,9 @@ bool CDVDPlayer::ShowPVRChannelInfo(void) { bool bReturn(false); - if (g_guiSettings.GetBool("pvrmenu.infoswitch")) + if (CSettings::Get().GetBool("pvrmenu.infoswitch")) { - int iTimeout = g_guiSettings.GetBool("pvrmenu.infotimeout") ? g_guiSettings.GetInt("pvrmenu.infotime") : 0; + int iTimeout = CSettings::Get().GetBool("pvrmenu.infotimeout") ? CSettings::Get().GetInt("pvrmenu.infotime") : 0; g_PVRManager.ShowPlayerInfo(iTimeout); bReturn = true; diff --git a/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp b/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp index 3c55b52bd3eae..e2ea4584952c1 100644 --- a/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp @@ -25,7 +25,7 @@ #include "DVDCodecs/DVDCodecs.h" #include "DVDCodecs/DVDFactoryCodec.h" #include "DVDPerformanceCounter.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "video/VideoReferenceClock.h" #include "utils/log.h" #include "utils/TimeUtils.h" @@ -145,7 +145,7 @@ CDVDPlayerAudio::~CDVDPlayerAudio() bool CDVDPlayerAudio::OpenStream( CDVDStreamInfo &hints ) { - bool passthrough = AUDIO_IS_BITSTREAM(g_guiSettings.GetInt("audiooutput.mode")); + bool passthrough = AUDIO_IS_BITSTREAM(CSettings::Get().GetInt("audiooutput.mode")); CLog::Log(LOGNOTICE, "Finding audio codec for: %i", hints.codec); CDVDAudioCodec* codec = CDVDFactoryCodec::CreateAudioCodec(hints, passthrough); @@ -191,8 +191,8 @@ void CDVDPlayerAudio::OpenStream( CDVDStreamInfo &hints, CDVDAudioCodec* codec ) m_synctype = SYNC_DISCON; m_setsynctype = SYNC_DISCON; - if (g_guiSettings.GetBool("videoplayer.usedisplayasclock")) - m_setsynctype = g_guiSettings.GetInt("videoplayer.synctype"); + if (CSettings::Get().GetBool("videoplayer.usedisplayasclock")) + m_setsynctype = CSettings::Get().GetInt("videoplayer.synctype"); m_prevsynctype = -1; m_error = 0; @@ -205,7 +205,7 @@ void CDVDPlayerAudio::OpenStream( CDVDStreamInfo &hints, CDVDAudioCodec* codec ) m_errortime = CurrentHostCounter(); m_silence = false; - m_maxspeedadjust = g_guiSettings.GetFloat("videoplayer.maxspeedadjust"); + m_maxspeedadjust = CSettings::Get().GetNumber("videoplayer.maxspeedadjust"); } void CDVDPlayerAudio::CloseStream(bool bWaitForBuffers) @@ -840,7 +840,7 @@ void CDVDPlayerAudio::WaitForBuffers() bool CDVDPlayerAudio::SwitchCodecIfNeeded() { // check if passthrough is disabled - if (!AUDIO_IS_BITSTREAM(g_guiSettings.GetInt("audiooutput.mode"))) + if (!AUDIO_IS_BITSTREAM(CSettings::Get().GetInt("audiooutput.mode"))) return false; CLog::Log(LOGDEBUG, "CDVDPlayerAudio: Sample rate changed, checking for passthrough"); diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp index 5585de2aa2de4..26cdbc402a60e 100644 --- a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp @@ -22,7 +22,6 @@ #include "cores/VideoRenderers/RenderFlags.h" #include "windowing/WindowingFactory.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" #include "settings/MediaSettings.h" #include "settings/Settings.h" #include "video/VideoReferenceClock.h" @@ -44,6 +43,7 @@ #include #include #include +#include "guilib/GraphicContext.h" #include "utils/log.h" using namespace std; @@ -204,7 +204,7 @@ bool CDVDPlayerVideo::OpenStream( CDVDStreamInfo &hint ) return false; } - if(g_guiSettings.GetBool("videoplayer.usedisplayasclock") && !g_VideoReferenceClock.IsRunning()) + if(CSettings::Get().GetBool("videoplayer.usedisplayasclock") && !g_VideoReferenceClock.IsRunning()) { g_VideoReferenceClock.Create(); //we have to wait for the clock to start otherwise alsa can cause trouble @@ -234,8 +234,8 @@ void CDVDPlayerVideo::OpenStream(CDVDStreamInfo &hint, CDVDVideoCodec* codec) m_bFpsInvalid = (hint.fpsrate == 0 || hint.fpsscale == 0); - m_bCalcFrameRate = g_guiSettings.GetBool("videoplayer.usedisplayasclock") || - g_guiSettings.GetInt("videoplayer.adjustrefreshrate") != ADJUST_REFRESHRATE_OFF; + m_bCalcFrameRate = CSettings::Get().GetBool("videoplayer.usedisplayasclock") || + CSettings::Get().GetInt("videoplayer.adjustrefreshrate") != ADJUST_REFRESHRATE_OFF; ResetFrameRateCalc(); m_iDroppedRequest = 0; diff --git a/xbmc/cores/dvdplayer/DVDSubtitles/DVDSubtitlesLibass.cpp b/xbmc/cores/dvdplayer/DVDSubtitles/DVDSubtitlesLibass.cpp index 357593ee3bca5..0da385c8d7cd1 100644 --- a/xbmc/cores/dvdplayer/DVDSubtitles/DVDSubtitlesLibass.cpp +++ b/xbmc/cores/dvdplayer/DVDSubtitles/DVDSubtitlesLibass.cpp @@ -21,7 +21,7 @@ #include "DVDSubtitlesLibass.h" #include "DVDClock.h" #include "filesystem/SpecialProtocol.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/log.h" #include "threads/SingleLock.h" #include "threads/Atomics.h" @@ -77,8 +77,8 @@ CDVDSubtitlesLibass::CDVDSubtitlesLibass() //Setting default font to the Arial in \media\fonts (used if FontConfig fails) strPath = "special://xbmc/media/Fonts/"; - strPath += g_guiSettings.GetString("subtitles.font"); - int fc = !g_guiSettings.GetBool("subtitles.overrideassfonts"); + strPath += CSettings::Get().GetString("subtitles.font"); + int fc = !CSettings::Get().GetBool("subtitles.overrideassfonts"); m_dll.ass_set_margins(m_renderer, 0, 0, 0, 0); m_dll.ass_set_use_margins(m_renderer, 0); diff --git a/xbmc/cores/omxplayer/OMXAudio.cpp b/xbmc/cores/omxplayer/OMXAudio.cpp index 273d0b2bb6cdb..3395372e65d3c 100644 --- a/xbmc/cores/omxplayer/OMXAudio.cpp +++ b/xbmc/cores/omxplayer/OMXAudio.cpp @@ -33,7 +33,8 @@ #include "linux/XMemUtils.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" +#include "settings/MediaSettings.h" +#include "settings/Settings.h" #include "guilib/LocalizeStrings.h" #include "cores/AudioEngine/Utils/AEConvert.h" @@ -710,7 +711,7 @@ bool COMXAudio::SetCurrentVolume(float fVolume) const float* coeff = downmixing_coefficients_8; // normally we normalalise the levels, can be skipped (boosted) at risk of distortion - if(!g_guiSettings.GetBool("audiooutput.normalizelevels")) + if(!CSettings::Get().GetBool("audiooutput.normalizelevels")) { double sum_L = 0; double sum_R = 0; diff --git a/xbmc/cores/omxplayer/OMXImage.cpp b/xbmc/cores/omxplayer/OMXImage.cpp index 7ab856d3de50a..674e0fc11251c 100644 --- a/xbmc/cores/omxplayer/OMXImage.cpp +++ b/xbmc/cores/omxplayer/OMXImage.cpp @@ -34,9 +34,9 @@ #include #include #include "guilib/GraphicContext.h" -#include "settings/DisplaySettings.h" -#include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" +#include "settings/DisplaySettings.h" +#include "settings/Settings.h" #ifdef CLASSNAME #undef CLASSNAME diff --git a/xbmc/cores/omxplayer/OMXPlayer.cpp b/xbmc/cores/omxplayer/OMXPlayer.cpp index 1b6cb5251b777..035439a49351e 100644 --- a/xbmc/cores/omxplayer/OMXPlayer.cpp +++ b/xbmc/cores/omxplayer/OMXPlayer.cpp @@ -39,7 +39,7 @@ #include "guilib/GUIWindowManager.h" #include "settings/AdvancedSettings.h" #include "settings/MediaSettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "threads/SingleLock.h" #include "windowing/WindowingFactory.h" @@ -142,7 +142,7 @@ static bool PredicateAudioPriority(const OMXSelectionStream& lh, const OMXSelect 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")) + if(!StringUtils::EqualsNoCase(CSettings::Get().GetString("locale.audiolanguage"), "original")) { CStdString audio_language = g_langInfo.GetAudioLanguage(); PREDICATE_RETURN(audio_language.Equals(lh.language.c_str()) @@ -172,7 +172,7 @@ static bool PredicateSubtitlePriority(const OMXSelectionStream& lh, const OMXSel , rh.type_index == CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream); CStdString subtitle_language = g_langInfo.GetSubtitleLanguage(); - if(!g_guiSettings.GetString("locale.subtitlelanguage").Equals("original")) + if(!StringUtils::EqualsNoCase(CSettings::Get().GetString("locale.subtitlelanguage"), "original")) { PREDICATE_RETURN((lh.source == STREAM_SOURCE_DEMUX_SUB || lh.source == STREAM_SOURCE_TEXT) && subtitle_language.Equals(lh.language.c_str()) , (rh.source == STREAM_SOURCE_DEMUX_SUB || rh.source == STREAM_SOURCE_TEXT) && subtitle_language.Equals(rh.language.c_str())); @@ -184,7 +184,7 @@ static bool PredicateSubtitlePriority(const OMXSelectionStream& lh, const OMXSel PREDICATE_RETURN(lh.source == STREAM_SOURCE_TEXT , rh.source == STREAM_SOURCE_TEXT); - if(!g_guiSettings.GetString("locale.subtitlelanguage").Equals("original")) + if(!StringUtils::EqualsNoCase(CSettings::Get().GetString("locale.subtitlelanguage"), "original")) { PREDICATE_RETURN(subtitle_language.Equals(lh.language.c_str()) , subtitle_language.Equals(rh.language.c_str())); @@ -457,7 +457,7 @@ bool COMXPlayer::OpenFile(const CFileItem &file, const CPlayerOptions &options) { return false; } - if(g_guiSettings.GetBool("videoplayer.adjustrefreshrate")) + if(CSettings::Get().GetBool("videoplayer.adjustrefreshrate")) m_av_clock.HDMIClockSync(); m_playSpeed = DVD_PLAYSPEED_NORMAL; @@ -584,7 +584,7 @@ bool COMXPlayer::OpenInputStream() if (filename.Left(7) == "http://" && filename.Right(5) == ".m3u8") { // get the available bandwidth (as per user settings) - int maxrate = g_guiSettings.GetInt("network.bandwidth"); + int maxrate = CSettings::Get().GetInt("network.bandwidth"); if(maxrate <= 0) maxrate = INT_MAX; @@ -2357,7 +2357,7 @@ void COMXPlayer::HandleMessages() if(input) { bool bSwitchSuccessful(false); - bool bShowPreview(g_guiSettings.GetInt("pvrplayback.channelentrytimeout") > 0); + bool bShowPreview(CSettings::Get().GetInt("pvrplayback.channelentrytimeout") > 0); if (!bShowPreview) { @@ -2375,7 +2375,7 @@ void COMXPlayer::HandleMessages() if (bShowPreview) { UpdateApplication(0); - m_iChannelEntryTimeOut = XbmcThreads::SystemClockMillis() + g_guiSettings.GetInt("pvrplayback.channelentrytimeout"); + m_iChannelEntryTimeOut = XbmcThreads::SystemClockMillis() + CSettings::Get().GetInt("pvrplayback.channelentrytimeout"); } else { @@ -2459,7 +2459,7 @@ void COMXPlayer::SetCaching(ECacheState state) m_player_video.SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1); if (state == CACHESTATE_PVR) - m_pInputStream->ResetScanTimeout((unsigned int) g_guiSettings.GetInt("pvrplayback.scantime") * 1000); + m_pInputStream->ResetScanTimeout((unsigned int) CSettings::Get().GetInt("pvrplayback.scantime") * 1000); } if(state == CACHESTATE_PLAY @@ -3554,9 +3554,9 @@ bool COMXPlayer::ShowPVRChannelInfo(void) { bool bReturn(false); - if (g_guiSettings.GetBool("pvrmenu.infoswitch")) + if (CSettings::Get().GetBool("pvrmenu.infoswitch")) { - int iTimeout = g_guiSettings.GetBool("pvrmenu.infotimeout") ? g_guiSettings.GetInt("pvrmenu.infotime") : 0; + int iTimeout = CSettings::Get().GetBool("pvrmenu.infotimeout") ? CSettings::Get().GetInt("pvrmenu.infotime") : 0; g_PVRManager.ShowPlayerInfo(iTimeout); bReturn = true; diff --git a/xbmc/cores/omxplayer/OMXPlayerAudio.cpp b/xbmc/cores/omxplayer/OMXPlayerAudio.cpp index 38344441f8d59..bacd11961a181 100644 --- a/xbmc/cores/omxplayer/OMXPlayerAudio.cpp +++ b/xbmc/cores/omxplayer/OMXPlayerAudio.cpp @@ -32,10 +32,9 @@ #include "linux/XMemUtils.h" #include "utils/BitstreamStats.h" -#include "settings/GUISettings.h" -#include "settings/Settings.h" #include "DVDDemuxers/DVDDemuxUtils.h" +#include "cores/AudioEngine/Utils/AEUtil.h" #include "utils/MathUtils.h" #include "settings/AdvancedSettings.h" #include "settings/Settings.h" @@ -165,7 +164,7 @@ void OMXPlayerAudio::OpenStream(CDVDStreamInfo &hints, COMXAudioCodecOMX *codec) m_nChannels = 0; m_synctype = SYNC_DISCON; m_stalled = m_messageQueue.GetPacketCount(CDVDMsg::DEMUXER_PACKET) == 0; - m_use_passthrough = (g_guiSettings.GetInt("audiooutput.mode") == AUDIO_HDMI) ? true : false ; + m_use_passthrough = (CSettings::Get().GetInt("audiooutput.mode") == AUDIO_HDMI) ? true : false ; m_use_hw_decode = g_advancedSettings.m_omxHWAudioDecode; } @@ -692,14 +691,14 @@ AEDataFormat OMXPlayerAudio::GetDataFormat(CDVDStreamInfo hints) /* check our audio capabilties */ /* pathrought is overriding hw decode*/ - if(AUDIO_IS_BITSTREAM(g_guiSettings.GetInt("audiooutput.mode")) && m_use_passthrough) + if(AUDIO_IS_BITSTREAM(CSettings::Get().GetInt("audiooutput.mode")) && m_use_passthrough) { - if(hints.codec == CODEC_ID_AC3 && g_guiSettings.GetBool("audiooutput.ac3passthrough") && hdmi_passthrough_ac3) + if(hints.codec == CODEC_ID_AC3 && CSettings::Get().GetBool("audiooutput.ac3passthrough") && hdmi_passthrough_ac3) { dataFormat = AE_FMT_AC3; m_passthrough = true; } - if(hints.codec == CODEC_ID_DTS && g_guiSettings.GetBool("audiooutput.dtspassthrough") && hdmi_passthrough_dts) + if(hints.codec == CODEC_ID_DTS && CSettings::Get().GetBool("audiooutput.dtspassthrough") && hdmi_passthrough_dts) { dataFormat = AE_FMT_DTS; m_passthrough = true; @@ -757,7 +756,7 @@ bool OMXPlayerAudio::OpenDecoder() std::string device = ""; - if(g_guiSettings.GetInt("audiooutput.mode") == AUDIO_HDMI) + if(CSettings::Get().GetInt("audiooutput.mode") == AUDIO_HDMI) device = "hdmi"; else device = "local"; diff --git a/xbmc/cores/omxplayer/OMXPlayerVideo.cpp b/xbmc/cores/omxplayer/OMXPlayerVideo.cpp index bd5711c15d105..9613e57e4fd61 100644 --- a/xbmc/cores/omxplayer/OMXPlayerVideo.cpp +++ b/xbmc/cores/omxplayer/OMXPlayerVideo.cpp @@ -41,7 +41,6 @@ #include "windowing/WindowingFactory.h" #include "DVDOverlayRenderer.h" #include "settings/DisplaySettings.h" -#include "settings/GUISettings.h" #include "settings/Settings.h" #include "settings/MediaSettings.h" #include "cores/VideoRenderers/RenderFormats.h" @@ -119,7 +118,7 @@ bool OMXPlayerVideo::OpenStream(CDVDStreamInfo &hints) m_hints = hints; 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_hdmi_clock_sync = (CSettings::Get().GetInt("videoplayer.adjustrefreshrate") != ADJUST_REFRESHRATE_OFF); m_started = false; m_flush = false; m_stalled = m_messageQueue.GetPacketCount(CDVDMsg::DEMUXER_PACKET) == 0; diff --git a/xbmc/cores/omxplayer/OMXVideo.cpp b/xbmc/cores/omxplayer/OMXVideo.cpp index 8e2e3da80085e..4443faec132d9 100644 --- a/xbmc/cores/omxplayer/OMXVideo.cpp +++ b/xbmc/cores/omxplayer/OMXVideo.cpp @@ -34,7 +34,6 @@ #include "settings/Settings.h" #include "utils/BitstreamConverter.h" - #include #include diff --git a/xbmc/cores/paplayer/AudioDecoder.cpp b/xbmc/cores/paplayer/AudioDecoder.cpp index 95440fa1b28c3..b0201b477db36 100644 --- a/xbmc/cores/paplayer/AudioDecoder.cpp +++ b/xbmc/cores/paplayer/AudioDecoder.cpp @@ -20,15 +20,14 @@ #include "AudioDecoder.h" #include "CodecFactory.h" -#include "settings/GUISettings.h" +#include "Application.h" +#include "settings/Settings.h" #include "FileItem.h" #include "music/tags/MusicInfoTag.h" #include "threads/SingleLock.h" #include "utils/log.h" #include -ReplayGainSettings CAudioDecoder::m_replayGainSettings; - CAudioDecoder::CAudioDecoder() { m_codec = NULL; @@ -74,13 +73,13 @@ bool CAudioDecoder::Create(const CFileItem &file, int64_t seekOffset) m_eof = false; // get correct cache size - unsigned int filecache = g_guiSettings.GetInt("cacheaudio.internet"); + unsigned int filecache = CSettings::Get().GetInt("cacheaudio.internet"); if ( file.IsHD() ) - filecache = g_guiSettings.GetInt("cache.harddisk"); + filecache = CSettings::Get().GetInt("cache.harddisk"); else if ( file.IsOnDVD() ) - filecache = g_guiSettings.GetInt("cacheaudio.dvdrom"); + filecache = CSettings::Get().GetInt("cacheaudio.dvdrom"); else if ( file.IsOnLAN() ) - filecache = g_guiSettings.GetInt("cacheaudio.lan"); + filecache = CSettings::Get().GetInt("cacheaudio.lan"); // create our codec m_codec=CodecFactory::CreateCodecDemux(file.GetPath(), file.GetMimeType(), filecache * 1024); @@ -243,42 +242,43 @@ int CAudioDecoder::ReadSamples(int numsamples) float CAudioDecoder::GetReplayGain() { #define REPLAY_GAIN_DEFAULT_LEVEL 89.0f - if (m_replayGainSettings.iType == REPLAY_GAIN_NONE) + const ReplayGainSettings &replayGainSettings = g_application.GetReplayGainSettings(); + if (replayGainSettings.iType == REPLAY_GAIN_NONE) return 1.0f; // Compute amount of gain - float replaydB = (float)m_replayGainSettings.iNoGainPreAmp; + float replaydB = (float)replayGainSettings.iNoGainPreAmp; float peak = 0.0f; - if (m_replayGainSettings.iType == REPLAY_GAIN_ALBUM) + if (replayGainSettings.iType == REPLAY_GAIN_ALBUM) { if (m_codec->m_tag.HasReplayGainInfo() & REPLAY_GAIN_HAS_ALBUM_INFO) { - replaydB = (float)m_replayGainSettings.iPreAmp + (float)m_codec->m_tag.GetReplayGainAlbumGain() * 0.01f; + replaydB = (float)replayGainSettings.iPreAmp + (float)m_codec->m_tag.GetReplayGainAlbumGain() * 0.01f; peak = m_codec->m_tag.GetReplayGainAlbumPeak(); } else if (m_codec->m_tag.HasReplayGainInfo() & REPLAY_GAIN_HAS_TRACK_INFO) { - replaydB = (float)m_replayGainSettings.iPreAmp + (float)m_codec->m_tag.GetReplayGainTrackGain() * 0.01f; + replaydB = (float)replayGainSettings.iPreAmp + (float)m_codec->m_tag.GetReplayGainTrackGain() * 0.01f; peak = m_codec->m_tag.GetReplayGainTrackPeak(); } } - else if (m_replayGainSettings.iType == REPLAY_GAIN_TRACK) + else if (replayGainSettings.iType == REPLAY_GAIN_TRACK) { if (m_codec->m_tag.HasReplayGainInfo() & REPLAY_GAIN_HAS_TRACK_INFO) { - replaydB = (float)m_replayGainSettings.iPreAmp + (float)m_codec->m_tag.GetReplayGainTrackGain() * 0.01f; + replaydB = (float)replayGainSettings.iPreAmp + (float)m_codec->m_tag.GetReplayGainTrackGain() * 0.01f; peak = m_codec->m_tag.GetReplayGainTrackPeak(); } else if (m_codec->m_tag.HasReplayGainInfo() & REPLAY_GAIN_HAS_ALBUM_INFO) { - replaydB = (float)m_replayGainSettings.iPreAmp + (float)m_codec->m_tag.GetReplayGainAlbumGain() * 0.01f; + replaydB = (float)replayGainSettings.iPreAmp + (float)m_codec->m_tag.GetReplayGainAlbumGain() * 0.01f; peak = m_codec->m_tag.GetReplayGainAlbumPeak(); } } // convert to a gain type float replaygain = pow(10.0f, (replaydB - REPLAY_GAIN_DEFAULT_LEVEL)* 0.05f); // check peaks - if (m_replayGainSettings.bAvoidClipping) + if (replayGainSettings.bAvoidClipping) { if (fabs(peak * replaygain) > 1.0f) replaygain = 1.0f / fabs(peak); diff --git a/xbmc/cores/paplayer/AudioDecoder.h b/xbmc/cores/paplayer/AudioDecoder.h index a933f4d5087c5..14cd0ed87d4c4 100644 --- a/xbmc/cores/paplayer/AudioDecoder.h +++ b/xbmc/cores/paplayer/AudioDecoder.h @@ -50,24 +50,12 @@ class CFileItem; #define RET_SUCCESS 0 #define RET_SLEEP 1 -// replay gain settings struct for quick access by the player multiple -// times per second (saves doing settings lookup) -struct ReplayGainSettings -{ - int iPreAmp; - int iNoGainPreAmp; - int iType; - bool bAvoidClipping; -}; - class CAudioDecoder { public: CAudioDecoder(); ~CAudioDecoder(); - static ReplayGainSettings& GetReplayGainSettings() { return m_replayGainSettings; } - bool Create(const CFileItem &file, int64_t seekOffset); void Destroy(); @@ -89,8 +77,6 @@ class CAudioDecoder float GetReplayGain(); private: - static ReplayGainSettings m_replayGainSettings; - // pcm buffer CRingBuffer m_pcmBuffer; diff --git a/xbmc/cores/paplayer/DVDPlayerCodec.cpp b/xbmc/cores/paplayer/DVDPlayerCodec.cpp index 562c96d68eeb3..edf0eb6251937 100644 --- a/xbmc/cores/paplayer/DVDPlayerCodec.cpp +++ b/xbmc/cores/paplayer/DVDPlayerCodec.cpp @@ -27,7 +27,7 @@ #include "cores/dvdplayer/DVDStreamInfo.h" #include "cores/dvdplayer/DVDCodecs/DVDFactoryCodec.h" #include "utils/log.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "URL.h" #include "AudioDecoder.h" @@ -132,7 +132,7 @@ bool DVDPlayerCodec::Init(const CStdString &strFile, unsigned int filecache) CDVDStreamInfo hint(*pStream, true); - bool passthrough = AUDIO_IS_BITSTREAM(g_guiSettings.GetInt("audiooutput.mode")); + bool passthrough = AUDIO_IS_BITSTREAM(CSettings::Get().GetInt("audiooutput.mode")); m_pAudioCodec = CDVDFactoryCodec::CreateAudioCodec(hint, passthrough); if (!m_pAudioCodec) { diff --git a/xbmc/cores/paplayer/PAPlayer.cpp b/xbmc/cores/paplayer/PAPlayer.cpp index 8ab075e5a5e26..cfde8fbf6b4c0 100644 --- a/xbmc/cores/paplayer/PAPlayer.cpp +++ b/xbmc/cores/paplayer/PAPlayer.cpp @@ -22,7 +22,6 @@ #include "CodecFactory.h" #include "FileItem.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" #include "settings/Settings.h" #include "music/tags/MusicInfoTag.h" #include "utils/TimeUtils.h" @@ -224,7 +223,7 @@ void PAPlayer::CloseAllStreams(bool fade/* = true */) bool PAPlayer::OpenFile(const CFileItem& file, const CPlayerOptions &options) { - m_defaultCrossfadeMS = g_guiSettings.GetInt("musicplayer.crossfade") * 1000; + m_defaultCrossfadeMS = CSettings::Get().GetInt("musicplayer.crossfade") * 1000; if (m_streams.size() > 1 || !m_defaultCrossfadeMS || m_isPaused) { @@ -260,12 +259,12 @@ bool PAPlayer::OpenFile(const CFileItem& file, const CPlayerOptions &options) void PAPlayer::UpdateCrossfadeTime(const CFileItem& file) { - m_upcomingCrossfadeMS = m_defaultCrossfadeMS = g_guiSettings.GetInt("musicplayer.crossfade") * 1000; + m_upcomingCrossfadeMS = m_defaultCrossfadeMS = CSettings::Get().GetInt("musicplayer.crossfade") * 1000; if (m_upcomingCrossfadeMS) { if (m_streams.size() == 0 || ( - file.HasMusicInfoTag() && !g_guiSettings.GetBool("musicplayer.crossfadealbumtracks") && + file.HasMusicInfoTag() && !CSettings::Get().GetBool("musicplayer.crossfadealbumtracks") && m_FileItem->HasMusicInfoTag() && (m_FileItem->GetMusicInfoTag()->GetAlbum() != "") && (m_FileItem->GetMusicInfoTag()->GetAlbum() == file.GetMusicInfoTag()->GetAlbum()) && diff --git a/xbmc/cores/playercorefactory/PlayerCoreFactory.cpp b/xbmc/cores/playercorefactory/PlayerCoreFactory.cpp index 8775c17226d09..5e57f335b3f9a 100644 --- a/xbmc/cores/playercorefactory/PlayerCoreFactory.cpp +++ b/xbmc/cores/playercorefactory/PlayerCoreFactory.cpp @@ -21,12 +21,13 @@ #include "utils/BitstreamStats.h" #include "PlayerCoreFactory.h" #include "threads/SingleLock.h" +#include "cores/AudioEngine/Utils/AEUtil.h" #include "cores/dvdplayer/DVDPlayer.h" #include "cores/paplayer/PAPlayer.h" #include "cores/paplayer/DVDPlayerCodec.h" #include "dialogs/GUIDialogContextMenu.h" #include "utils/HttpHeader.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "URL.h" #include "FileItem.h" #include "profiles/ProfilesManager.h" @@ -80,7 +81,7 @@ template void unique (T &con) IPlayer* CPlayerCoreFactory::CreatePlayer(const CStdString& strCore, IPlayerCallback& callback) const { - return CreatePlayer( GetPlayerCore(strCore), callback ); + return CreatePlayer(GetPlayerCore(strCore), callback ); } IPlayer* CPlayerCoreFactory::CreatePlayer(const PLAYERCOREID eCore, IPlayerCallback& callback) const @@ -188,7 +189,7 @@ void CPlayerCoreFactory::GetPlayers( const CFileItem& item, VECPLAYERCORES &vecC if (bAdd) { - if( g_guiSettings.GetInt("audiooutput.mode") == AUDIO_ANALOG ) + if( CSettings::Get().GetInt("audiooutput.mode") == AUDIO_ANALOG ) { CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers: adding PAPlayer (%d)", EPC_PAPLAYER); vecCores.push_back(EPC_PAPLAYER); @@ -298,6 +299,7 @@ PLAYERCOREID CPlayerCoreFactory::SelectPlayerDialog(float posX, float posY) cons bool CPlayerCoreFactory::LoadConfiguration(const std::string &file, bool clear) { CSingleLock lock(m_section); + CLog::Log(LOGNOTICE, "Loading player core factory settings from %s.", file.c_str()); if (!XFILE::CFile::Exists(file)) { // tell the user it doesn't exist diff --git a/xbmc/cores/playercorefactory/PlayerCoreFactory.h b/xbmc/cores/playercorefactory/PlayerCoreFactory.h index 559ee0fae142b..1f9405dab0756 100644 --- a/xbmc/cores/playercorefactory/PlayerCoreFactory.h +++ b/xbmc/cores/playercorefactory/PlayerCoreFactory.h @@ -20,15 +20,14 @@ * */ -#include "system.h" +#include +#include "system.h" #include "cores/IPlayerCallback.h" #include "settings/ISettingsHandler.h" #include "threads/CriticalSection.h" #include "utils/StdString.h" -#include - /*---------------------------------------------------------------------- | forward references +---------------------------------------------------------------------*/ diff --git a/xbmc/cores/playercorefactory/PlayerSelectionRule.cpp b/xbmc/cores/playercorefactory/PlayerSelectionRule.cpp index 52361a0c07c00..f3ba67563f405 100644 --- a/xbmc/cores/playercorefactory/PlayerSelectionRule.cpp +++ b/xbmc/cores/playercorefactory/PlayerSelectionRule.cpp @@ -22,7 +22,7 @@ #include "PlayerSelectionRule.h" #include "video/VideoInfoTag.h" #include "utils/StreamDetails.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/log.h" #include "utils/RegExp.h" #include "utils/XBMCTinyXML.h" @@ -67,7 +67,7 @@ void CPlayerSelectionRule::Initialize(TiXmlElement* pRule) m_bStreamDetails = m_audioCodec.length() > 0 || m_audioChannels.length() > 0 || m_videoCodec.length() > 0 || m_videoResolution.length() > 0 || m_videoAspect.length() > 0; - if (m_bStreamDetails && !g_guiSettings.GetBool("myvideos.extractflags")) + if (m_bStreamDetails && !CSettings::Get().GetBool("myvideos.extractflags")) { CLog::Log(LOGWARNING, "CPlayerSelectionRule::Initialize: rule: %s needs media flagging, which is disabled", m_name.c_str()); } diff --git a/xbmc/dialogs/GUIDialogContextMenu.cpp b/xbmc/dialogs/GUIDialogContextMenu.cpp index 3c95aaab2e939..da7d4854f134f 100644 --- a/xbmc/dialogs/GUIDialogContextMenu.cpp +++ b/xbmc/dialogs/GUIDialogContextMenu.cpp @@ -28,8 +28,8 @@ #include "GUIPassword.h" #include "Util.h" #include "utils/URIUtils.h" -#include "settings/GUISettings.h" #include "settings/MediaSourceSettings.h" +#include "settings/Settings.h" #include "GUIDialogMediaSource.h" #include "profiles/ProfilesManager.h" #include "profiles/dialogs/GUIDialogLockSettings.h" @@ -40,7 +40,6 @@ #include "addons/AddonManager.h" #include "FileItem.h" #include "filesystem/File.h" -#include "settings/Settings.h" #include "guilib/LocalizeStrings.h" #include "TextureCache.h" #include "video/windows/GUIWindowVideoBase.h" @@ -368,8 +367,8 @@ void CGUIDialogContextMenu::GetContextButtons(const CStdString &type, const CFil buttons.Add(CONTEXT_BUTTON_REMOVE_LOCK, 12335); bool maxRetryExceeded = false; - if (g_guiSettings.GetInt("masterlock.maxretries") != 0) - maxRetryExceeded = (share->m_iBadPwdCount >= g_guiSettings.GetInt("masterlock.maxretries")); + if (CSettings::Get().GetInt("masterlock.maxretries") != 0) + maxRetryExceeded = (share->m_iBadPwdCount >= CSettings::Get().GetInt("masterlock.maxretries")); if (maxRetryExceeded) buttons.Add(CONTEXT_BUTTON_RESET_LOCK, 12334); @@ -607,8 +606,8 @@ bool CGUIDialogContextMenu::OnContextButton(const CStdString &type, const CFileI case CONTEXT_BUTTON_REACTIVATE_LOCK: { bool maxRetryExceeded = false; - if (g_guiSettings.GetInt("masterlock.maxretries") != 0) - maxRetryExceeded = (share->m_iBadPwdCount >= g_guiSettings.GetInt("masterlock.maxretries")); + if (CSettings::Get().GetInt("masterlock.maxretries") != 0) + maxRetryExceeded = (share->m_iBadPwdCount >= CSettings::Get().GetInt("masterlock.maxretries")); if (!maxRetryExceeded) { // don't prompt user for mastercode when reactivating a lock diff --git a/xbmc/dialogs/GUIDialogFileBrowser.cpp b/xbmc/dialogs/GUIDialogFileBrowser.cpp index 31d2ef5d39001..95f6a4ea034fa 100644 --- a/xbmc/dialogs/GUIDialogFileBrowser.cpp +++ b/xbmc/dialogs/GUIDialogFileBrowser.cpp @@ -40,8 +40,8 @@ #include "filesystem/MultiPathDirectory.h" #include "profiles/ProfilesManager.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" #include "settings/MediaSourceSettings.h" +#include "settings/Settings.h" #include "guilib/Key.h" #include "guilib/LocalizeStrings.h" #include "utils/log.h" diff --git a/xbmc/dialogs/GUIDialogMediaSource.cpp b/xbmc/dialogs/GUIDialogMediaSource.cpp index 0c8f39baec6cf..8314e1403e7f4 100644 --- a/xbmc/dialogs/GUIDialogMediaSource.cpp +++ b/xbmc/dialogs/GUIDialogMediaSource.cpp @@ -31,8 +31,8 @@ #include "filesystem/PVRDirectory.h" #include "GUIDialogYesNo.h" #include "FileItem.h" -#include "settings/GUISettings.h" #include "settings/MediaSourceSettings.h" +#include "settings/Settings.h" #include "guilib/LocalizeStrings.h" #include "PasswordManager.h" #include "URL.h" @@ -252,13 +252,12 @@ void CGUIDialogMediaSource::OnPathBrowse(int item) share1.strName = "SAP Streams"; extraShares.push_back(share1); - if (g_guiSettings.GetString("audiocds.recordingpath",false) != "") + if (CSettings::Get().GetString("audiocds.recordingpath") != "") { share1.strPath = "special://recordings/"; share1.strName = g_localizeStrings.Get(21883); extraShares.push_back(share1); } - } else if (m_type == "video") { @@ -326,7 +325,7 @@ void CGUIDialogMediaSource::OnPathBrowse(int item) #endif share1.m_ignore = true; - if (g_guiSettings.GetString("debug.screenshotpath",false)!= "") + if (CSettings::Get().GetString("debug.screenshotpath") != "") { share1.strPath = "special://screenshots/"; share1.strName = g_localizeStrings.Get(20008); diff --git a/xbmc/dialogs/GUIDialogSeekBar.cpp b/xbmc/dialogs/GUIDialogSeekBar.cpp index 22e9ad36a6706..60ac273430f5b 100644 --- a/xbmc/dialogs/GUIDialogSeekBar.cpp +++ b/xbmc/dialogs/GUIDialogSeekBar.cpp @@ -24,7 +24,6 @@ #include "GUIInfoManager.h" #include "utils/TimeUtils.h" #include "FileItem.h" -#include "settings/GUISettings.h" #include "utils/SeekHandler.h" #define SEEK_BAR_DISPLAY_TIME 2000L diff --git a/xbmc/dialogs/GUIDialogSmartPlaylistEditor.cpp b/xbmc/dialogs/GUIDialogSmartPlaylistEditor.cpp index 451be19223ea6..80642906e9b50 100644 --- a/xbmc/dialogs/GUIDialogSmartPlaylistEditor.cpp +++ b/xbmc/dialogs/GUIDialogSmartPlaylistEditor.cpp @@ -21,12 +21,13 @@ #include "GUIDialogSmartPlaylistEditor.h" #include "guilib/GUIKeyboardFactory.h" #include "Util.h" +#include "utils/StringUtils.h" #include "utils/URIUtils.h" #include "GUIDialogSmartPlaylistRule.h" #include "guilib/GUIWindowManager.h" #include "filesystem/File.h" #include "profiles/ProfilesManager.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "FileItem.h" #include "guilib/Key.h" #include "guilib/LocalizeStrings.h" @@ -166,7 +167,7 @@ void CGUIDialogSmartPlaylistEditor::OnOK() CStdString path; if (CGUIKeyboardFactory::ShowAndGetInput(filename, g_localizeStrings.Get(16013), false)) { - path = URIUtils::AddFileToFolder(g_guiSettings.GetString("system.playlistspath"),m_playlist.GetSaveLocation()); + path = URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"),m_playlist.GetSaveLocation()); path = URIUtils::AddFileToFolder(path, CUtil::MakeLegalFileName(filename)); } else @@ -181,14 +182,14 @@ void CGUIDialogSmartPlaylistEditor::OnOK() { // check if we need to actually change the save location for this playlist // this occurs if the user switches from music video <> songs <> mixed - if (m_path.Left(g_guiSettings.GetString("system.playlistspath").size()).Equals(g_guiSettings.GetString("system.playlistspath"))) // fugly, well aware + if (StringUtils::EqualsNoCase(m_path.Left(CSettings::Get().GetString("system.playlistspath").size()), CSettings::Get().GetString("system.playlistspath"))) // fugly, well aware { CStdString filename = URIUtils::GetFileName(m_path); - CStdString strFolder = m_path.Mid(g_guiSettings.GetString("system.playlistspath").size(),m_path.size()-filename.size()-g_guiSettings.GetString("system.playlistspath").size()-1); + CStdString strFolder = m_path.Mid(CSettings::Get().GetString("system.playlistspath").size(),m_path.size()-filename.size()-CSettings::Get().GetString("system.playlistspath").size()-1); if (strFolder != m_playlist.GetSaveLocation()) { // move to the correct folder XFILE::CFile::Delete(m_path); - m_path = URIUtils::AddFileToFolder(g_guiSettings.GetString("system.playlistspath"),m_playlist.GetSaveLocation()); + m_path = URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"),m_playlist.GetSaveLocation()); m_path = URIUtils::AddFileToFolder(m_path, filename); } } diff --git a/xbmc/epg/Epg.cpp b/xbmc/epg/Epg.cpp index cfef9fd9b4a55..eef85ca134c52 100644 --- a/xbmc/epg/Epg.cpp +++ b/xbmc/epg/Epg.cpp @@ -20,7 +20,7 @@ #include "guilib/LocalizeStrings.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "threads/SingleLock.h" #include "utils/log.h" #include "utils/TimeUtils.h" @@ -425,7 +425,7 @@ CDateTime CEpg::GetLastScanTime(void) if (!m_lastScanTime.IsValid()) { - if (!g_guiSettings.GetBool("epg.ignoredbforclient")) + if (!CSettings::Get().GetBool("epg.ignoredbforclient")) { CEpgDatabase *database = g_EpgContainer.GetDatabase(); CDateTime dtReturn; dtReturn.SetValid(false); @@ -530,7 +530,7 @@ int CEpg::Get(CFileItemList &results, const EpgSearchFilter &filter) const bool CEpg::Persist(void) { - if (g_guiSettings.GetBool("epg.ignoredbforclient") || !NeedsSave()) + if (CSettings::Get().GetBool("epg.ignoredbforclient") || !NeedsSave()) return true; #if EPG_DEBUGGING @@ -788,13 +788,13 @@ bool CEpg::LoadFromClients(time_t start, time_t end) { CEpg tmpEpg(channel); if (tmpEpg.UpdateFromScraper(start, end)) - bReturn = UpdateEntries(tmpEpg, !g_guiSettings.GetBool("epg.ignoredbforclient")); + bReturn = UpdateEntries(tmpEpg, !CSettings::Get().GetBool("epg.ignoredbforclient")); } else { CEpg tmpEpg(m_iEpgID, m_strName, m_strScraperName); if (tmpEpg.UpdateFromScraper(start, end)) - bReturn = UpdateEntries(tmpEpg, !g_guiSettings.GetBool("epg.ignoredbforclient")); + bReturn = UpdateEntries(tmpEpg, !CSettings::Get().GetBool("epg.ignoredbforclient")); } return bReturn; diff --git a/xbmc/epg/EpgContainer.cpp b/xbmc/epg/EpgContainer.cpp index baa4220567930..7307bbf26da9d 100644 --- a/xbmc/epg/EpgContainer.cpp +++ b/xbmc/epg/EpgContainer.cpp @@ -21,7 +21,7 @@ #include "Application.h" #include "threads/SingleLock.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "dialogs/GUIDialogExtendedProgressBar.h" #include "dialogs/GUIDialogProgress.h" #include "guilib/GUIWindowManager.h" @@ -131,7 +131,6 @@ void CEpgContainer::Start(void) m_bIsInitialising = true; m_bStop = false; - g_guiSettings.RegisterObserver(this); LoadSettings(); m_iNextEpgUpdate = 0; @@ -157,14 +156,19 @@ bool CEpgContainer::Stop(void) void CEpgContainer::Notify(const Observable &obs, const ObservableMessage msg) { - /* settings were updated */ - if (msg == ObservableMessageGuiSettings) + SetChanged(); + NotifyObservers(msg); +} + +void CEpgContainer::OnSettingChanged(const CSetting *setting) +{ + if (setting == NULL) + return; + + const std::string &settingId = setting->GetId(); + if (settingId == "epg.ignoredbforclient" || settingId == "epg.epgupdate" || + settingId == "epg.daystodisplay") LoadSettings(); - else - { - SetChanged(); - NotifyObservers(msg); - } } void CEpgContainer::LoadFromDB(void) @@ -275,8 +279,6 @@ void CEpgContainer::Process(void) Sleep(1000); } - - g_guiSettings.UnregisterObserver(this); } CEpg *CEpgContainer::GetById(int iEpgId) const @@ -359,9 +361,9 @@ CEpg *CEpgContainer::CreateChannelEpg(CPVRChannelPtr channel) bool CEpgContainer::LoadSettings(void) { - m_bIgnoreDbForClient = g_guiSettings.GetBool("epg.ignoredbforclient"); - m_iUpdateTime = g_guiSettings.GetInt ("epg.epgupdate") * 60; - m_iDisplayTime = g_guiSettings.GetInt ("epg.daystodisplay") * 24 * 60 * 60; + m_bIgnoreDbForClient = CSettings::Get().GetBool("epg.ignoredbforclient"); + m_iUpdateTime = CSettings::Get().GetInt ("epg.epgupdate") * 60; + m_iDisplayTime = CSettings::Get().GetInt ("epg.daystodisplay") * 24 * 60 * 60; return true; } @@ -447,7 +449,7 @@ bool CEpgContainer::InterruptUpdate(void) const lock.Leave(); return bReturn || - (g_guiSettings.GetBool("epg.preventupdateswhileplayingtv") && + (CSettings::Get().GetBool("epg.preventupdateswhileplayingtv") && g_PVRManager.IsStarted() && g_PVRManager.IsPlaying()); } diff --git a/xbmc/epg/EpgContainer.h b/xbmc/epg/EpgContainer.h index 7b27c4ce4c698..7b9166e112691 100644 --- a/xbmc/epg/EpgContainer.h +++ b/xbmc/epg/EpgContainer.h @@ -21,6 +21,7 @@ */ #include "XBDateTime.h" +#include "settings/ISettingCallback.h" #include "threads/CriticalSection.h" #include "threads/Thread.h" #include "utils/Observer.h" @@ -38,8 +39,9 @@ namespace EPG #define g_EpgContainer CEpgContainer::Get() class CEpgContainer : public Observer, - public Observable, - private CThread + public Observable, + public ISettingCallback, + private CThread { friend class CEpgDatabase; @@ -107,6 +109,8 @@ namespace EPG */ virtual void Notify(const Observable &obs, const ObservableMessage msg); + virtual void OnSettingChanged(const CSetting *setting); + CEpg *CreateChannelEpg(PVR::CPVRChannelPtr channel); /*! diff --git a/xbmc/epg/EpgInfoTag.cpp b/xbmc/epg/EpgInfoTag.cpp index c6dfb474902c8..b2783d6504499 100644 --- a/xbmc/epg/EpgInfoTag.cpp +++ b/xbmc/epg/EpgInfoTag.cpp @@ -27,7 +27,7 @@ #include "pvr/timers/PVRTimers.h" #include "pvr/PVRManager.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/log.h" #include "utils/Variant.h" #include "addons/include/xbmc_pvr_types.h" @@ -444,7 +444,7 @@ CStdString CEpgInfoTag::Title(bool bOverrideParental /* = false */) const if (!bOverrideParental && bParentalLocked) strTitle = g_localizeStrings.Get(19266); // parental locked - else if (strTitle.empty() && !g_guiSettings.GetBool("epg.hidenoinfoavailable")) + else if (strTitle.empty() && !CSettings::Get().GetBool("epg.hidenoinfoavailable")) strTitle = g_localizeStrings.Get(19055); // no information available return strTitle; diff --git a/xbmc/filesystem/AFPFile.cpp b/xbmc/filesystem/AFPFile.cpp index 05d17dd55fca7..921e350e67521 100644 --- a/xbmc/filesystem/AFPFile.cpp +++ b/xbmc/filesystem/AFPFile.cpp @@ -30,7 +30,6 @@ #include "AFPDirectory.h" #include "Util.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" #include "threads/SingleLock.h" #include "utils/log.h" #include "utils/TimeUtils.h" diff --git a/xbmc/filesystem/CurlFile.cpp b/xbmc/filesystem/CurlFile.cpp index c70676f8293a5..da0847333734c 100644 --- a/xbmc/filesystem/CurlFile.cpp +++ b/xbmc/filesystem/CurlFile.cpp @@ -23,7 +23,7 @@ #include "Util.h" #include "URL.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "File.h" #include @@ -725,19 +725,19 @@ void CCurlFile::ParseAndCorrectUrl(CURL &url2) else if( strProtocol.Equals("http") || strProtocol.Equals("https")) { - if (g_guiSettings.GetBool("network.usehttpproxy") - && !g_guiSettings.GetString("network.httpproxyserver").empty() - && !g_guiSettings.GetString("network.httpproxyport").empty() + if (CSettings::Get().GetBool("network.usehttpproxy") + && !CSettings::Get().GetString("network.httpproxyserver").empty() + && !CSettings::Get().GetString("network.httpproxyport").empty() && m_proxy.IsEmpty()) { - m_proxy = g_guiSettings.GetString("network.httpproxyserver"); - m_proxy += ":" + g_guiSettings.GetString("network.httpproxyport"); - if (g_guiSettings.GetString("network.httpproxyusername").length() > 0 && m_proxyuserpass.IsEmpty()) + m_proxy = CSettings::Get().GetString("network.httpproxyserver"); + m_proxy += ":" + CSettings::Get().GetString("network.httpproxyport"); + if (CSettings::Get().GetString("network.httpproxyusername").length() > 0 && m_proxyuserpass.IsEmpty()) { - m_proxyuserpass = g_guiSettings.GetString("network.httpproxyusername"); - m_proxyuserpass += ":" + g_guiSettings.GetString("network.httpproxypassword"); + m_proxyuserpass = CSettings::Get().GetString("network.httpproxyusername"); + m_proxyuserpass += ":" + CSettings::Get().GetString("network.httpproxypassword"); } - m_proxytype = (ProxyType)g_guiSettings.GetInt("network.httpproxytype"); + m_proxytype = (ProxyType)CSettings::Get().GetInt("network.httpproxytype"); CLog::Log(LOGDEBUG, "Using proxy %s, type %d", m_proxy.c_str(), proxyType2CUrlProxyType[m_proxytype]); } diff --git a/xbmc/filesystem/Directory.cpp b/xbmc/filesystem/Directory.cpp index dac2e7ac32e50..9624b48b272ee 100644 --- a/xbmc/filesystem/Directory.cpp +++ b/xbmc/filesystem/Directory.cpp @@ -24,7 +24,7 @@ #include "commons/Exception.h" #include "FileItem.h" #include "DirectoryCache.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/log.h" #include "utils/Job.h" #include "utils/JobManager.h" @@ -209,7 +209,7 @@ bool CDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items, c // TODO: we shouldn't be checking the gui setting here; // callers should use getHidden instead if ((!item->m_bIsFolder && !pDirectory->IsAllowed(item->GetPath())) || - (item->GetProperty("file:hidden").asBoolean() && !(hints.flags & DIR_FLAG_GET_HIDDEN) && !g_guiSettings.GetBool("filelists.showhidden"))) + (item->GetProperty("file:hidden").asBoolean() && !(hints.flags & DIR_FLAG_GET_HIDDEN) && !CSettings::Get().GetBool("filelists.showhidden"))) { items.Remove(i); i--; // don't confuse loop diff --git a/xbmc/filesystem/HTSPDirectory.cpp b/xbmc/filesystem/HTSPDirectory.cpp index 8331cf9a300ba..87d307d1212ff 100644 --- a/xbmc/filesystem/HTSPDirectory.cpp +++ b/xbmc/filesystem/HTSPDirectory.cpp @@ -22,7 +22,7 @@ #include "HTSPDirectory.h" #include "URL.h" #include "FileItem.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "guilib/LocalizeStrings.h" #include "cores/dvdplayer/DVDInputStreams/DVDInputStreamHTSP.h" #include "threads/SingleLock.h" @@ -391,12 +391,12 @@ bool CHTSPDirectory::GetChannels( const CURL &base items.AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS("%K[ - %B]", "%Z", "%L", "")); - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) items.AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%B", "%Z", "%L", "")); else items.AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%B", "%Z", "%L", "")); - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) items.AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%Z", "%B", "%L", "")); else items.AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%Z", "%B", "%L", "")); diff --git a/xbmc/filesystem/MusicDatabaseDirectory/DirectoryNodeArtist.cpp b/xbmc/filesystem/MusicDatabaseDirectory/DirectoryNodeArtist.cpp index 2bbc6c705a7a8..5ce4974242015 100644 --- a/xbmc/filesystem/MusicDatabaseDirectory/DirectoryNodeArtist.cpp +++ b/xbmc/filesystem/MusicDatabaseDirectory/DirectoryNodeArtist.cpp @@ -21,7 +21,7 @@ #include "DirectoryNodeArtist.h" #include "QueryParams.h" #include "music/MusicDatabase.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" using namespace XFILE::MUSICDATABASEDIRECTORY; @@ -55,7 +55,7 @@ bool CDirectoryNodeArtist::GetContent(CFileItemList& items) const CQueryParams params; CollectQueryParams(params); - bool bSuccess = musicdatabase.GetArtistsNav(BuildPath(), items, !g_guiSettings.GetBool("musiclibrary.showcompilationartists"), params.GetGenreId()); + bool bSuccess = musicdatabase.GetArtistsNav(BuildPath(), items, !CSettings::Get().GetBool("musiclibrary.showcompilationartists"), params.GetGenreId()); musicdatabase.Close(); diff --git a/xbmc/filesystem/MythDirectory.cpp b/xbmc/filesystem/MythDirectory.cpp index e0ce987224ba4..5e234770cc8fc 100644 --- a/xbmc/filesystem/MythDirectory.cpp +++ b/xbmc/filesystem/MythDirectory.cpp @@ -24,8 +24,8 @@ #include "DllLibCMyth.h" #include "video/VideoInfoTag.h" #include "URL.h" -#include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" +#include "settings/Settings.h" #include "FileItem.h" #include "utils/StringUtils.h" #include "guilib/LocalizeStrings.h" @@ -326,7 +326,7 @@ bool CMythDirectory::GetRecordings(const CStdString& base, CFileItemList &items, */ if (type != TV_SHOWS) { - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) items.AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 556, LABEL_MASKS("%K", "%J")); else items.AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556, LABEL_MASKS("%K", "%J")); @@ -392,7 +392,7 @@ bool CMythDirectory::GetTvShowFolders(const CStdString& base, CFileItemList &ite } m_dll->ref_release(list); - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) items.AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551 /* Name */, LABEL_MASKS("", "", "%L", "%J")); else items.AddSortMethod(SORT_METHOD_LABEL, 551 /* Name */, LABEL_MASKS("", "", "%L", "%J")); @@ -469,7 +469,7 @@ bool CMythDirectory::GetChannels(const CStdString& base, CFileItemList &items) /* * Video sort title is set to the channel number. */ - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) items.AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 556 /* Title */, LABEL_MASKS("%K", "%B")); else items.AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556 /* Title */, LABEL_MASKS("%K", "%B")); diff --git a/xbmc/filesystem/PluginDirectory.cpp b/xbmc/filesystem/PluginDirectory.cpp index aff6c68b291fd..59e0aa4b3dce6 100644 --- a/xbmc/filesystem/PluginDirectory.cpp +++ b/xbmc/filesystem/PluginDirectory.cpp @@ -32,7 +32,7 @@ #include "threads/SingleLock.h" #include "guilib/GUIWindowManager.h" #include "dialogs/GUIDialogProgress.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "FileItem.h" #include "video/VideoInfoTag.h" #include "guilib/LocalizeStrings.h" @@ -231,7 +231,7 @@ void CPluginDirectory::AddSortMethod(int handle, SORT_METHOD sortMethod, const C case SORT_METHOD_LABEL: case SORT_METHOD_LABEL_IGNORE_THE: { - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) dir->m_listItems->AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%T", label2Mask)); else dir->m_listItems->AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", label2Mask)); @@ -240,7 +240,7 @@ void CPluginDirectory::AddSortMethod(int handle, SORT_METHOD sortMethod, const C case SORT_METHOD_TITLE: case SORT_METHOD_TITLE_IGNORE_THE: { - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) dir->m_listItems->AddSortMethod(SORT_METHOD_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T", label2Mask)); else dir->m_listItems->AddSortMethod(SORT_METHOD_TITLE, 556, LABEL_MASKS("%T", label2Mask)); @@ -249,7 +249,7 @@ void CPluginDirectory::AddSortMethod(int handle, SORT_METHOD sortMethod, const C case SORT_METHOD_ARTIST: case SORT_METHOD_ARTIST_IGNORE_THE: { - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) dir->m_listItems->AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 557, LABEL_MASKS("%T", "%A")); else dir->m_listItems->AddSortMethod(SORT_METHOD_ARTIST, 557, LABEL_MASKS("%T", "%A")); @@ -258,7 +258,7 @@ void CPluginDirectory::AddSortMethod(int handle, SORT_METHOD sortMethod, const C case SORT_METHOD_ALBUM: case SORT_METHOD_ALBUM_IGNORE_THE: { - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) dir->m_listItems->AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%T", "%B")); else dir->m_listItems->AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%T", "%B")); @@ -327,7 +327,7 @@ void CPluginDirectory::AddSortMethod(int handle, SORT_METHOD sortMethod, const C case SORT_METHOD_VIDEO_SORT_TITLE: case SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE: { - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) dir->m_listItems->AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T", label2Mask)); else dir->m_listItems->AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556, LABEL_MASKS("%T", label2Mask)); @@ -346,7 +346,7 @@ void CPluginDirectory::AddSortMethod(int handle, SORT_METHOD sortMethod, const C case SORT_METHOD_STUDIO: case SORT_METHOD_STUDIO_IGNORE_THE: { - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) dir->m_listItems->AddSortMethod(SORT_METHOD_STUDIO_IGNORE_THE, 572, LABEL_MASKS("%T", "%U")); else dir->m_listItems->AddSortMethod(SORT_METHOD_STUDIO, 572, LABEL_MASKS("%T", "%U")); @@ -374,8 +374,8 @@ void CPluginDirectory::AddSortMethod(int handle, SORT_METHOD sortMethod, const C } case SORT_METHOD_PLAYLIST_ORDER: { - CStdString strTrackLeft=g_guiSettings.GetString("musicfiles.trackformat"); - CStdString strTrackRight=g_guiSettings.GetString("musicfiles.trackformatright"); + CStdString strTrackLeft=CSettings::Get().GetString("musicfiles.trackformat"); + CStdString strTrackRight=CSettings::Get().GetString("musicfiles.trackformatright"); dir->m_listItems->AddSortMethod(SORT_METHOD_PLAYLIST_ORDER, 559, LABEL_MASKS(strTrackLeft, strTrackRight)); break; diff --git a/xbmc/filesystem/RSSDirectory.cpp b/xbmc/filesystem/RSSDirectory.cpp index 1c702ae638996..dabab2937b1e7 100644 --- a/xbmc/filesystem/RSSDirectory.cpp +++ b/xbmc/filesystem/RSSDirectory.cpp @@ -22,6 +22,8 @@ #include "FileItem.h" #include "CurlFile.h" #include "settings/AdvancedSettings.h" +#include "settings/MediaSettings.h" +#include "settings/Settings.h" #include "utils/URIUtils.h" #include "utils/XBMCTinyXML.h" #include "utils/HTMLUtil.h" @@ -30,7 +32,6 @@ #include "music/tags/MusicInfoTag.h" #include "utils/log.h" #include "URL.h" -#include "settings/GUISettings.h" #include "climits" #include "threads/SingleLock.h" @@ -491,7 +492,7 @@ static void ParseItem(CFileItem* item, TiXmlElement* root, const CStdString& pat else if(FindMime(resources, "image/")) mime = "image/"; - int maxrate = g_guiSettings.GetInt("network.bandwidth"); + int maxrate = CSettings::Get().GetInt("network.bandwidth"); if(maxrate == 0) maxrate = INT_MAX; diff --git a/xbmc/filesystem/ShoutcastFile.cpp b/xbmc/filesystem/ShoutcastFile.cpp index 9f674d280dfb5..5c81be0980e3f 100644 --- a/xbmc/filesystem/ShoutcastFile.cpp +++ b/xbmc/filesystem/ShoutcastFile.cpp @@ -26,7 +26,6 @@ #include "threads/SystemClock.h" #include "system.h" #include "ShoutcastFile.h" -#include "settings/GUISettings.h" #include "guilib/GUIWindowManager.h" #include "URL.h" #include "utils/RegExp.h" diff --git a/xbmc/filesystem/SmartPlaylistDirectory.cpp b/xbmc/filesystem/SmartPlaylistDirectory.cpp index 2c99e2f558d46..d353fa9101014 100644 --- a/xbmc/filesystem/SmartPlaylistDirectory.cpp +++ b/xbmc/filesystem/SmartPlaylistDirectory.cpp @@ -26,7 +26,7 @@ #include "filesystem/File.h" #include "music/MusicDatabase.h" #include "playlists/SmartPlayList.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/log.h" #include "utils/StringUtils.h" #include "utils/URIUtils.h" @@ -70,7 +70,7 @@ namespace XFILE sorting.limitEnd = playlist.GetLimit(); sorting.sortBy = playlist.GetOrder(); sorting.sortOrder = playlist.GetOrderAscending() ? SortOrderAscending : SortOrderDescending; - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) sorting.sortAttributes = SortAttributeIgnoreArticle; std::string option = !filter ? "xsp" : "filter"; diff --git a/xbmc/filesystem/SmbFile.cpp b/xbmc/filesystem/SmbFile.cpp index 1080a04a13264..07c66b15c6e6b 100644 --- a/xbmc/filesystem/SmbFile.cpp +++ b/xbmc/filesystem/SmbFile.cpp @@ -29,9 +29,10 @@ #include "Util.h" #include #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "threads/SingleLock.h" #include "utils/log.h" +#include "utils/StringUtils.h" #include "utils/TimeUtils.h" #include "commons/Exception.h" @@ -122,9 +123,9 @@ void CSMB::Init() // set wins server if there's one. name resolve order defaults to 'lmhosts host wins bcast'. // if no WINS server has been specified the wins method will be ignored. - if ( g_guiSettings.GetString("smb.winsserver").length() > 0 && !g_guiSettings.GetString("smb.winsserver").Equals("0.0.0.0") ) + if (CSettings::Get().GetString("smb.winsserver").length() > 0 && !StringUtils::EqualsNoCase(CSettings::Get().GetString("smb.winsserver"), "0.0.0.0") ) { - fprintf(f, "\twins server = %s\n", g_guiSettings.GetString("smb.winsserver").c_str()); + fprintf(f, "\twins server = %s\n", CSettings::Get().GetString("smb.winsserver").c_str()); fprintf(f, "\tname resolve order = bcast wins host\n"); } else @@ -136,8 +137,8 @@ void CSMB::Init() fprintf(f, "\tdos charset = %s\n", g_advancedSettings.m_sambadoscodepage.c_str()); // if no workgroup string is specified, samba will use the default value 'WORKGROUP' - if ( g_guiSettings.GetString("smb.workgroup").length() > 0 ) - fprintf(f, "\tworkgroup = %s\n", g_guiSettings.GetString("smb.workgroup").c_str()); + if ( CSettings::Get().GetString("smb.workgroup").length() > 0 ) + fprintf(f, "\tworkgroup = %s\n", CSettings::Get().GetString("smb.workgroup").c_str()); fclose(f); } } @@ -182,9 +183,9 @@ void CSMB::Init() #ifdef TARGET_WINDOWS // if a wins-server is set, we have to change name resolve order to - if ( g_guiSettings.GetString("smb.winsserver").length() > 0 && !g_guiSettings.GetString("smb.winsserver").Equals("0.0.0.0") ) + if ( CSettings::Get().GetString("smb.winsserver").length() > 0 && !CSettings::Get().GetString("smb.winsserver").Equals("0.0.0.0") ) { - lp_do_parameter( -1, "wins server", g_guiSettings.GetString("smb.winsserver").c_str()); + lp_do_parameter( -1, "wins server", CSettings::Get().GetString("smb.winsserver").c_str()); lp_do_parameter( -1, "name resolve order", "bcast wins host"); } else diff --git a/xbmc/filesystem/SpecialProtocol.cpp b/xbmc/filesystem/SpecialProtocol.cpp index ee96019c98c0b..f955361493362 100644 --- a/xbmc/filesystem/SpecialProtocol.cpp +++ b/xbmc/filesystem/SpecialProtocol.cpp @@ -24,7 +24,7 @@ #include "guilib/GraphicContext.h" #include "profiles/ProfilesManager.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/log.h" #include "utils/URIUtils.h" @@ -129,7 +129,7 @@ CStdString CSpecialProtocol::TranslatePath(const CURL &url) RootDir = FullFileName; if (RootDir.Equals("subtitles")) - URIUtils::AddFileToFolder(g_guiSettings.GetString("subtitles.custompath"), FileName, translatedPath); + URIUtils::AddFileToFolder(CSettings::Get().GetString("subtitles.custompath"), FileName, translatedPath); else if (RootDir.Equals("userdata")) URIUtils::AddFileToFolder(CProfilesManager::Get().GetUserDataFolder(), FileName, translatedPath); else if (RootDir.Equals("database")) @@ -137,9 +137,9 @@ CStdString CSpecialProtocol::TranslatePath(const CURL &url) else if (RootDir.Equals("thumbnails")) URIUtils::AddFileToFolder(CProfilesManager::Get().GetThumbnailsFolder(), FileName, translatedPath); else if (RootDir.Equals("recordings") || RootDir.Equals("cdrips")) - URIUtils::AddFileToFolder(g_guiSettings.GetString("audiocds.recordingpath", false), FileName, translatedPath); + URIUtils::AddFileToFolder(CSettings::Get().GetString("audiocds.recordingpath"), FileName, translatedPath); else if (RootDir.Equals("screenshots")) - URIUtils::AddFileToFolder(g_guiSettings.GetString("debug.screenshotpath", false), FileName, translatedPath); + URIUtils::AddFileToFolder(CSettings::Get().GetString("debug.screenshotpath"), FileName, translatedPath); else if (RootDir.Equals("musicplaylists")) URIUtils::AddFileToFolder(CUtil::MusicPlaylistsLocation(), FileName, translatedPath); else if (RootDir.Equals("videoplaylists")) diff --git a/xbmc/filesystem/VideoDatabaseDirectory.cpp b/xbmc/filesystem/VideoDatabaseDirectory.cpp index 8e4da794a9d0b..6b0635dd64162 100644 --- a/xbmc/filesystem/VideoDatabaseDirectory.cpp +++ b/xbmc/filesystem/VideoDatabaseDirectory.cpp @@ -25,7 +25,7 @@ #include "guilib/TextureManager.h" #include "File.h" #include "FileItem.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/Crc32.h" #include "guilib/LocalizeStrings.h" #include "utils/log.h" @@ -229,7 +229,7 @@ CStdString CVideoDatabaseDirectory::GetIcon(const CStdString &strDirectory) case NODE_TYPE_TITLE_MOVIES: if (strDirectory.Equals("videodb://movies/titles/")) { - if (g_guiSettings.GetBool("myvideos.flatten")) + if (CSettings::Get().GetBool("myvideos.flatten")) return "DefaultMovies.png"; return "DefaultMovieTitle.png"; } @@ -237,7 +237,7 @@ CStdString CVideoDatabaseDirectory::GetIcon(const CStdString &strDirectory) case NODE_TYPE_TITLE_TVSHOWS: if (strDirectory.Equals("videodb://tvshows/titles/")) { - if (g_guiSettings.GetBool("myvideos.flatten")) + if (CSettings::Get().GetBool("myvideos.flatten")) return "DefaultTVShows.png"; return "DefaultTVShowTitle.png"; } @@ -245,7 +245,7 @@ CStdString CVideoDatabaseDirectory::GetIcon(const CStdString &strDirectory) case NODE_TYPE_TITLE_MUSICVIDEOS: if (strDirectory.Equals("videodb://musicvideos/titles/")) { - if (g_guiSettings.GetBool("myvideos.flatten")) + if (CSettings::Get().GetBool("myvideos.flatten")) return "DefaultMusicVideos.png"; return "DefaultMusicVideoTitle.png"; } diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeOverview.cpp b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeOverview.cpp index ecdedc96850d8..019c6f287cf2e 100644 --- a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeOverview.cpp +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeOverview.cpp @@ -20,7 +20,7 @@ #include "video/VideoDatabase.h" #include "DirectoryNodeOverview.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "FileItem.h" #include "guilib/LocalizeStrings.h" #include "video/VideoDbUrl.h" @@ -71,21 +71,21 @@ bool CDirectoryNodeOverview::GetContent(CFileItemList& items) const vector > vec; if (hasMovies) { - if (g_guiSettings.GetBool("myvideos.flatten")) + if (CSettings::Get().GetBool("myvideos.flatten")) vec.push_back(make_pair("movies/titles", 342)); else vec.push_back(make_pair("movies", 342)); // Movies } if (hasTvShows) { - if (g_guiSettings.GetBool("myvideos.flatten")) + if (CSettings::Get().GetBool("myvideos.flatten")) vec.push_back(make_pair("tvshows/titles", 20343)); else vec.push_back(make_pair("tvshows", 20343)); // TV Shows } if (hasMusicVideos) { - if (g_guiSettings.GetBool("myvideos.flatten")) + if (CSettings::Get().GetBool("myvideos.flatten")) vec.push_back(make_pair("musicvideos/titles", 20389)); else vec.push_back(make_pair("musicvideos", 20389)); // Music Videos diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeSeasons.cpp b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeSeasons.cpp index aaaab2a7c1d27..c0902a15bd7b7 100644 --- a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeSeasons.cpp +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeSeasons.cpp @@ -22,8 +22,8 @@ #include "QueryParams.h" #include "video/VideoDatabase.h" #include "video/VideoDbUrl.h" -#include "settings/GUISettings.h" #include "settings/MediaSettings.h" +#include "settings/Settings.h" #include "FileItem.h" #include "utils/Variant.h" @@ -71,14 +71,14 @@ bool CDirectoryNodeSeasons::GetContent(CFileItemList& items) const CQueryParams params; CollectQueryParams(params); - int iFlatten = g_guiSettings.GetInt("videolibrary.flattentvshows"); + int iFlatten = CSettings::Get().GetInt("videolibrary.flattentvshows"); bool bSuccess=videodatabase.GetSeasonsNav(BuildPath(), items, params.GetActorId(), params.GetDirectorId(), params.GetGenreId(), params.GetYear(), params.GetTvShowId()); bool bFlatten = (items.GetObjectCount() == 1 && iFlatten == 1) || iFlatten == 2; if (items.GetObjectCount() == 2 && iFlatten == 1) if (items[0]->GetVideoInfoTag()->m_iSeason == 0 || items[1]->GetVideoInfoTag()->m_iSeason == 0) bFlatten = true; // flatten if one season + specials - if (iFlatten > 0 && !bFlatten && CMediaSettings::Get().GetWatchedMode("tvshows") == WatchedModeUnwatched) + if (iFlatten > 0 && !bFlatten && CMediaSettings::Get().GetWatchedMode("tvshows") == WatchedModeUnwatched) { int count = 0; for(int i = 0; i < items.Size(); i++) diff --git a/xbmc/filesystem/test/TestFileFactory.cpp b/xbmc/filesystem/test/TestFileFactory.cpp index 732e53b35e552..52cf7a0a4acb4 100644 --- a/xbmc/filesystem/test/TestFileFactory.cpp +++ b/xbmc/filesystem/test/TestFileFactory.cpp @@ -20,8 +20,7 @@ #include "filesystem/File.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" -#include "utils/XBMCTinyXML.h" +#include "settings/Settings.h" #include "test/TestUtils.h" #include "gtest/gtest.h" @@ -31,26 +30,29 @@ class TestFileFactory : public testing::Test protected: TestFileFactory() { - std::vector advancedsettings = - CXBMCTestUtils::Instance().getAdvancedSettingsFiles(); - std::vector guisettings = - CXBMCTestUtils::Instance().getGUISettingsFiles(); - std::vector::iterator it; - for (it = advancedsettings.begin(); it < advancedsettings.end(); it++) + if (CSettings::Get().Initialize()) { - g_advancedSettings.ParseSettingsFile(*it); - } - for (it = guisettings.begin(); it < guisettings.end(); it++) - { - CXBMCTinyXML xml(*it); - g_guiSettings.LoadXML(xml.RootElement()); - } + std::vector advancedsettings = + CXBMCTestUtils::Instance().getAdvancedSettingsFiles(); + std::vector guisettings = + CXBMCTestUtils::Instance().getGUISettingsFiles(); + + std::vector::iterator it; + for (it = guisettings.begin(); it < guisettings.end(); it++) + CSettings::Get().Load(*it); + + for (it = advancedsettings.begin(); it < advancedsettings.end(); it++) + g_advancedSettings.ParseSettingsFile(*it); + + CSettings::Get().SetLoaded(); + } } ~TestFileFactory() { g_advancedSettings.Clear(); - g_guiSettings.Clear(); + CSettings::Get().Unload(); + CSettings::Get().Uninitialize(); } }; diff --git a/xbmc/filesystem/test/TestRarFile.cpp b/xbmc/filesystem/test/TestRarFile.cpp index a29430249fdca..e63ae700e3257 100644 --- a/xbmc/filesystem/test/TestRarFile.cpp +++ b/xbmc/filesystem/test/TestRarFile.cpp @@ -23,7 +23,6 @@ #include "filesystem/Directory.h" #include "filesystem/File.h" #include "filesystem/NFSFile.h" -#include "settings/GUISettings.h" #include "utils/URIUtils.h" #include "FileItem.h" #include "test/TestUtils.h" diff --git a/xbmc/filesystem/test/TestZipFile.cpp b/xbmc/filesystem/test/TestZipFile.cpp index 923a7c5fe7ce4..7f94680e62fd0 100644 --- a/xbmc/filesystem/test/TestZipFile.cpp +++ b/xbmc/filesystem/test/TestZipFile.cpp @@ -20,9 +20,9 @@ #include "filesystem/Directory.h" #include "filesystem/File.h" -#include "settings/GUISettings.h" #include "utils/URIUtils.h" #include "FileItem.h" +#include "settings/Settings.h" #include "test/TestUtils.h" #include @@ -37,19 +37,21 @@ class TestZipFile : public testing::Test /* Add default settings for locale. * Settings here are taken from CGUISettings::Initialize() */ - CSettingsCategory *loc = g_guiSettings.AddCategory(7, "locale", 14090); - g_guiSettings.AddString(loc, "locale.language",248,"english", + /* TODO + CSettingsCategory *loc = CSettings::Get().AddCategory(7, "locale", 14090); + CSettings::Get().AddString(loc, "locale.language",248,"english", SPIN_CONTROL_TEXT); - g_guiSettings.AddString(loc, "locale.country", 20026, "USA", + CSettings::Get().AddString(loc, "locale.country", 20026, "USA", SPIN_CONTROL_TEXT); - g_guiSettings.AddString(loc, "locale.charset", 14091, "DEFAULT", + CSettings::Get().AddString(loc, "locale.charset", 14091, "DEFAULT", SPIN_CONTROL_TEXT); // charset is set by the // language file + */ } ~TestZipFile() { - g_guiSettings.Clear(); + CSettings::Get().Unload(); } }; diff --git a/xbmc/filesystem/windows/WINFileSMB.cpp b/xbmc/filesystem/windows/WINFileSMB.cpp index c54145473ce1a..b46355a58d62f 100644 --- a/xbmc/filesystem/windows/WINFileSMB.cpp +++ b/xbmc/filesystem/windows/WINFileSMB.cpp @@ -20,7 +20,7 @@ */ #include "WINFileSMB.h" #include "URL.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include #include @@ -343,4 +343,4 @@ int CWINFileSMB::Truncate(int64_t size) int result = _chsize_s(fd, (long) size); _close(fd); return result; -} \ No newline at end of file +} diff --git a/xbmc/filesystem/windows/WINSMBDirectory.cpp b/xbmc/filesystem/windows/WINSMBDirectory.cpp index f840870fabb92..c69ea28a96eaf 100644 --- a/xbmc/filesystem/windows/WINSMBDirectory.cpp +++ b/xbmc/filesystem/windows/WINSMBDirectory.cpp @@ -22,7 +22,7 @@ #include "WINSMBDirectory.h" #include "URL.h" #include "utils/URIUtils.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "FileItem.h" #include "WIN32Util.h" #include "utils/AutoPtrHandle.h" diff --git a/xbmc/guilib/GUIAudioManager.cpp b/xbmc/guilib/GUIAudioManager.cpp index 8b0fa947a3094..3143b9f6d5238 100644 --- a/xbmc/guilib/GUIAudioManager.cpp +++ b/xbmc/guilib/GUIAudioManager.cpp @@ -21,7 +21,6 @@ #include "system.h" #include "GUIAudioManager.h" #include "Key.h" -#include "settings/GUISettings.h" #include "input/ButtonTranslator.h" #include "threads/SingleLock.h" #include "utils/URIUtils.h" @@ -42,6 +41,19 @@ CGUIAudioManager::~CGUIAudioManager() { } +void CGUIAudioManager::OnSettingChanged(const CSetting *setting) +{ + if (setting == NULL) + return; + + const std::string &settingId = setting->GetId(); + if (settingId == "lookandfeel.soundskin") + { + Enable(true); + Load(); + } +} + void CGUIAudioManager::Initialize() { } @@ -189,17 +201,17 @@ bool CGUIAudioManager::Load() UnLoad(); - if (g_guiSettings.GetString("lookandfeel.soundskin")=="OFF") + if (CSettings::Get().GetString("lookandfeel.soundskin")=="OFF") return true; else Enable(true); - if (g_guiSettings.GetString("lookandfeel.soundskin")=="SKINDEFAULT") + if (CSettings::Get().GetString("lookandfeel.soundskin")=="SKINDEFAULT") { m_strMediaDir = URIUtils::AddFileToFolder(g_SkinInfo->Path(), "sounds"); } else - m_strMediaDir = URIUtils::AddFileToFolder("special://xbmc/sounds", g_guiSettings.GetString("lookandfeel.soundskin")); + m_strMediaDir = URIUtils::AddFileToFolder("special://xbmc/sounds", CSettings::Get().GetString("lookandfeel.soundskin")); CStdString strSoundsXml = URIUtils::AddFileToFolder(m_strMediaDir, "sounds.xml"); @@ -339,7 +351,7 @@ IAESound* CGUIAudioManager::LoadWindowSound(TiXmlNode* pWindowNode, const CStdSt void CGUIAudioManager::Enable(bool bEnable) { // always deinit audio when we don't want gui sounds - if (g_guiSettings.GetString("lookandfeel.soundskin")=="OFF") + if (CSettings::Get().GetString("lookandfeel.soundskin")=="OFF") bEnable = false; CSingleLock lock(m_cs); diff --git a/xbmc/guilib/GUIAudioManager.h b/xbmc/guilib/GUIAudioManager.h index 625c2b933ed0d..99b5ba06a4f5a 100644 --- a/xbmc/guilib/GUIAudioManager.h +++ b/xbmc/guilib/GUIAudioManager.h @@ -20,12 +20,13 @@ * */ +#include + +#include "cores/AudioEngine/Interfaces/AESound.h" +#include "settings/ISettingCallback.h" #include "threads/CriticalSection.h" #include "utils/log.h" #include "utils/StdString.h" -#include "cores/AudioEngine/Interfaces/AESound.h" - -#include // forward definitions class CAction; @@ -34,7 +35,7 @@ class IAESound; enum WINDOW_SOUND { SOUND_INIT = 0, SOUND_DEINIT }; -class CGUIAudioManager +class CGUIAudioManager : public ISettingCallback { class CWindowSounds { @@ -54,6 +55,8 @@ class CGUIAudioManager CGUIAudioManager(); ~CGUIAudioManager(); + virtual void OnSettingChanged(const CSetting *setting); + void Initialize(); void DeInitialize(); diff --git a/xbmc/guilib/GUIControlFactory.cpp b/xbmc/guilib/GUIControlFactory.cpp index b6492e27f5761..6821cbad7f482 100644 --- a/xbmc/guilib/GUIControlFactory.cpp +++ b/xbmc/guilib/GUIControlFactory.cpp @@ -18,6 +18,7 @@ * */ +#include "system.h" #include "GUIControlFactory.h" #include "LocalizeStrings.h" #include "GUIButtonControl.h" @@ -59,10 +60,10 @@ #include "utils/XMLUtils.h" #include "GUIFontManager.h" #include "GUIColorManager.h" -#include "settings/Settings.h" #include "utils/RssManager.h" #include "utils/StringUtils.h" #include "GUIAction.h" +#include "utils/RssReader.h" using namespace std; using namespace EPG; diff --git a/xbmc/guilib/GUIFontManager.cpp b/xbmc/guilib/GUIFontManager.cpp index e8127ef3b40a7..8ca6ff5c0716b 100644 --- a/xbmc/guilib/GUIFontManager.cpp +++ b/xbmc/guilib/GUIFontManager.cpp @@ -26,13 +26,17 @@ #include "GUIFont.h" #include "utils/XMLUtils.h" #include "GUIControlFactory.h" +#include "filesystem/Directory.h" #include "filesystem/File.h" #include "filesystem/SpecialProtocol.h" +#include "settings/Setting.h" #include "utils/log.h" #include "utils/URIUtils.h" #include "utils/StringUtils.h" #include "windowing/WindowingFactory.h" +#include "FileItem.h" #include "URL.h" +#include "Util.h" using namespace std; @@ -576,3 +580,29 @@ bool GUIFontManager::IsFontSetUnicode(const CStdString& strFontSet) return false; } + +void GUIFontManager::SettingOptionsFontsFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t) +{ + CFileItemList items; + CFileItemList items2; + + // find TTF fonts + XFILE::CDirectory::GetDirectory("special://home/media/Fonts/", items2); + + if (XFILE::CDirectory::GetDirectory("special://xbmc/media/Fonts/", items)) + { + items.Append(items2); + for (int i = 0; i < items.Size(); ++i) + { + CFileItemPtr pItem = items[i]; + + if (!pItem->m_bIsFolder) + { + if (!URIUtils::GetExtension(pItem->GetLabel()).Equals(".ttf")) + continue; + + list.push_back(make_pair(pItem->GetLabel(), pItem->GetLabel())); + } + } + } +} diff --git a/xbmc/guilib/GUIFontManager.h b/xbmc/guilib/GUIFontManager.h index 40f8227a0d1ab..48b8e27d743d2 100644 --- a/xbmc/guilib/GUIFontManager.h +++ b/xbmc/guilib/GUIFontManager.h @@ -37,6 +37,7 @@ class CGUIFont; class CGUIFontTTFBase; class CXBMCTinyXML; class TiXmlNode; +class CSetting; struct OrigFontInfo { @@ -82,6 +83,8 @@ class GUIFontManager : public IMsgTargetCallback void ReloadTTFFonts(); void UnloadTTFFonts(); + static void SettingOptionsFontsFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t); + protected: void RescaleFontSizeAndAspect(float *size, float *aspect, const RESOLUTION_INFO &sourceRes, bool preserveAspect) const; void LoadFonts(const TiXmlNode* fontNode); diff --git a/xbmc/guilib/GUIFontTTF.cpp b/xbmc/guilib/GUIFontTTF.cpp index 4071c081e5bea..ef3018c45fc1b 100644 --- a/xbmc/guilib/GUIFontTTF.cpp +++ b/xbmc/guilib/GUIFontTTF.cpp @@ -27,7 +27,6 @@ #include "utils/MathUtils.h" #include "utils/log.h" #include "windowing/WindowingFactory.h" -#include "settings/GUISettings.h" #include diff --git a/xbmc/guilib/GUIKeyboardFactory.cpp b/xbmc/guilib/GUIKeyboardFactory.cpp index a019b95c95c28..493f995e36b38 100644 --- a/xbmc/guilib/GUIKeyboardFactory.cpp +++ b/xbmc/guilib/GUIKeyboardFactory.cpp @@ -19,13 +19,13 @@ */ #include "Application.h" +#include "ApplicationMessenger.h" #include "LocalizeStrings.h" #include "GUIKeyboardFactory.h" #include "dialogs/GUIDialogOK.h" #include "GUIUserMessages.h" #include "GUIWindowManager.h" -#include "settings/GUISettings.h" -#include "ApplicationMessenger.h" +#include "settings/Settings.h" #include "utils/md5.h" @@ -190,7 +190,7 @@ int CGUIKeyboardFactory::ShowAndVerifyPassword(CStdString& strPassword, const CS if (1 > iRetries && strHeading.size()) strHeadingTemp = strHeading; else - strHeadingTemp.Format("%s - %i %s", g_localizeStrings.Get(12326).c_str(), g_guiSettings.GetInt("masterlock.maxretries") - iRetries, g_localizeStrings.Get(12343).c_str()); + strHeadingTemp.Format("%s - %i %s", g_localizeStrings.Get(12326).c_str(), CSettings::Get().GetInt("masterlock.maxretries") - iRetries, g_localizeStrings.Get(12343).c_str()); CStdString strUserInput = ""; if (!ShowAndGetInput(strUserInput, strHeadingTemp, false, true, autoCloseMs)) //bool hiddenInput = false/true ? TODO: GUI Setting to enable disable this feature y/n? diff --git a/xbmc/guilib/GUIListContainer.cpp b/xbmc/guilib/GUIListContainer.cpp index 6e11a6dfff6f2..9b0243e6bf64b 100644 --- a/xbmc/guilib/GUIListContainer.cpp +++ b/xbmc/guilib/GUIListContainer.cpp @@ -18,6 +18,7 @@ * */ +#include "system.h" #include "GUIListContainer.h" #include "GUIListItem.h" #include "Key.h" diff --git a/xbmc/guilib/GUIListItemLayout.cpp b/xbmc/guilib/GUIListItemLayout.cpp index ba45efb6282de..7d1a9fb316364 100644 --- a/xbmc/guilib/GUIListItemLayout.cpp +++ b/xbmc/guilib/GUIListItemLayout.cpp @@ -18,6 +18,7 @@ * */ +#include "system.h" #include "GUIListItemLayout.h" #include "FileItem.h" #include "GUIControlFactory.h" diff --git a/xbmc/guilib/GUIRSSControl.cpp b/xbmc/guilib/GUIRSSControl.cpp index 6dbf3be52955e..51c2454a39dbb 100644 --- a/xbmc/guilib/GUIRSSControl.cpp +++ b/xbmc/guilib/GUIRSSControl.cpp @@ -20,7 +20,7 @@ #include "GUIRSSControl.h" #include "GUIWindowManager.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "threads/CriticalSection.h" #include "threads/SingleLock.h" #include "utils/RssManager.h" @@ -112,7 +112,7 @@ void CGUIRSSControl::Process(unsigned int currentTime, CDirtyRegionList &dirtyre void CGUIRSSControl::Render() { // only render the control if they are enabled - if (g_guiSettings.GetBool("lookandfeel.enablerssfeeds") && CRssManager::Get().IsActive()) + if (CSettings::Get().GetBool("lookandfeel.enablerssfeeds") && CRssManager::Get().IsActive()) { CSingleLock lock(m_criticalSection); // Create RSS background/worker thread if needed diff --git a/xbmc/guilib/GUISpinControl.cpp b/xbmc/guilib/GUISpinControl.cpp index 660bf8e738361..c141cf286a949 100644 --- a/xbmc/guilib/GUISpinControl.cpp +++ b/xbmc/guilib/GUISpinControl.cpp @@ -207,8 +207,9 @@ void CGUISpinControl::OnRight() void CGUISpinControl::Clear() { - m_vecLabels.erase(m_vecLabels.begin(), m_vecLabels.end()); - m_vecValues.erase(m_vecValues.begin(), m_vecValues.end()); + m_vecLabels.clear(); + m_vecValues.clear(); + m_vecStrValues.clear(); SetValue(0); } @@ -492,7 +493,6 @@ void CGUISpinControl::SetRange(int iStart, int iEnd) m_iEnd = iEnd; } - void CGUISpinControl::SetFloatRange(float fStart, float fEnd) { m_fStart = fStart; @@ -532,6 +532,19 @@ void CGUISpinControl::SetFloatValue(float fValue) m_fValue = fValue; } +void CGUISpinControl::SetStringValue(const std::string& strValue) +{ + if (m_iType == SPIN_CONTROL_TYPE_TEXT) + { + m_iValue = 0; + for (unsigned int i = 0; i < m_vecStrValues.size(); i++) + if (strValue == m_vecStrValues[i]) + m_iValue = i; + } + + SetInvalid(); +} + int CGUISpinControl::GetValue() const { if (m_iType == SPIN_CONTROL_TYPE_TEXT) @@ -547,6 +560,17 @@ float CGUISpinControl::GetFloatValue() const return m_fValue; } +std::string CGUISpinControl::GetStringValue() const +{ + if (m_iType == SPIN_CONTROL_TYPE_TEXT && m_iValue >= 0 && m_iValue < (int)m_vecLabels.size()) + { + if (m_iValue < (int)m_vecStrValues.size()) + return m_vecStrValues[m_iValue]; + + return m_vecLabels[m_iValue]; + } + return ""; +} void CGUISpinControl::AddLabel(const string& strLabel, int iValue) { @@ -554,11 +578,17 @@ void CGUISpinControl::AddLabel(const string& strLabel, int iValue) m_vecValues.push_back(iValue); } +void CGUISpinControl::AddLabel(const string& strLabel, const string& strValue) +{ + m_vecLabels.push_back(strLabel); + m_vecStrValues.push_back(strValue); +} + const string CGUISpinControl::GetLabel() const { if (m_iValue >= 0 && m_iValue < (int)m_vecLabels.size()) { - return m_vecLabels[ m_iValue]; + return m_vecLabels[m_iValue]; } return ""; } diff --git a/xbmc/guilib/GUISpinControl.h b/xbmc/guilib/GUISpinControl.h index 3f2a54aaa5815..5624ce148cb4c 100644 --- a/xbmc/guilib/GUISpinControl.h +++ b/xbmc/guilib/GUISpinControl.h @@ -67,9 +67,12 @@ class CGUISpinControl : public CGUIControl void SetValue(int iValue); void SetValueFromLabel(const CStdString &label); void SetFloatValue(float fValue); + void SetStringValue(const std::string& strValue); int GetValue() const; float GetFloatValue() const; + std::string GetStringValue() const; void AddLabel(const std::string& strLabel, int iValue); + void AddLabel(const std::string& strLabel, const std::string& strValue); const std::string GetLabel() const; void SetReverse(bool bOnOff); int GetMaximum() const; @@ -117,6 +120,7 @@ class CGUISpinControl : public CGUIControl float m_fInterval; std::vector m_vecLabels; std::vector m_vecValues; + std::vector m_vecStrValues; CGUITexture m_imgspinUp; CGUITexture m_imgspinDown; CGUITexture m_imgspinUpFocus; diff --git a/xbmc/guilib/GUIWindow.cpp b/xbmc/guilib/GUIWindow.cpp index db92847842989..5e400769ddb93 100644 --- a/xbmc/guilib/GUIWindow.cpp +++ b/xbmc/guilib/GUIWindow.cpp @@ -26,7 +26,6 @@ #include "GUIControlFactory.h" #include "GUIControlGroup.h" #include "GUIControlProfiler.h" -#include "settings/Settings.h" #ifdef PRE_SKIN_VERSION_9_10_COMPATIBILITY #include "GUIEditControl.h" #endif diff --git a/xbmc/guilib/GUIWindowManager.cpp b/xbmc/guilib/GUIWindowManager.cpp index b4d7b59d8fa0a..039d3b1eebf68 100644 --- a/xbmc/guilib/GUIWindowManager.cpp +++ b/xbmc/guilib/GUIWindowManager.cpp @@ -27,8 +27,8 @@ #include "GUIInfoManager.h" #include "threads/SingleLock.h" #include "utils/URIUtils.h" -#include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" +#include "settings/Settings.h" #include "addons/Skin.h" #include "GUITexture.h" #include "windowing/WindowingFactory.h" @@ -360,7 +360,7 @@ void CGUIWindowManager::ActivateWindow_Internal(int iWindowID, const vectorGetId(); + if (settingId == "videoscreen.fakefullscreen") + { + if (IsFullScreenRoot()) + SetVideoResolution(GetVideoResolution(), true); + } +} + void CGraphicContext::SetOrigin(float x, float y) { if (m_origins.size()) @@ -279,7 +292,7 @@ void CGraphicContext::SetFullScreenVideo(bool bOnOff) #if defined(HAS_VIDEO_PLAYBACK) if(m_bFullScreenRoot) { - bool allowDesktopRes = g_guiSettings.GetInt("videoplayer.adjustrefreshrate") == ADJUST_REFRESHRATE_ALWAYS; + bool allowDesktopRes = CSettings::Get().GetInt("videoplayer.adjustrefreshrate") == ADJUST_REFRESHRATE_ALWAYS; if(m_bFullScreenVideo || (!allowDesktopRes && g_application.IsPlayingVideo())) SetVideoResolution(g_renderManager.GetResolution()); else if(CDisplaySettings::Get().GetCurrentResolution() > RES_DESKTOP) @@ -340,8 +353,8 @@ void CGraphicContext::SetVideoResolution(RESOLUTION res, bool forceUpdate) if ((res != RES_DESKTOP && res != RES_WINDOW) || (lastRes != RES_DESKTOP && lastRes != RES_WINDOW)) { //pause the player during the refreshrate change - int delay = g_guiSettings.GetInt("videoplayer.pauseafterrefreshchange"); - if (delay > 0 && g_guiSettings.GetInt("videoplayer.adjustrefreshrate") != ADJUST_REFRESHRATE_OFF && g_application.IsPlayingVideo() && !g_application.IsPaused()) + int delay = CSettings::Get().GetInt("videoplayer.pauseafterrefreshchange"); + if (delay > 0 && CSettings::Get().GetInt("videoplayer.adjustrefreshrate") != ADJUST_REFRESHRATE_OFF && g_application.IsPlayingVideo() && !g_application.IsPaused()) { g_application.m_pPlayer->Pause(); ThreadMessage msg = {TMSG_MEDIA_UNPAUSE}; @@ -375,7 +388,7 @@ void CGraphicContext::SetVideoResolution(RESOLUTION res, bool forceUpdate) if (g_advancedSettings.m_fullScreen) { #if defined (TARGET_DARWIN) || defined (_WIN32) - bool blankOtherDisplays = g_guiSettings.GetBool("videoscreen.blankdisplays"); + bool blankOtherDisplays = CSettings::Get().GetBool("videoscreen.blankdisplays"); g_Windowing.SetFullScreen(true, CDisplaySettings::Get().GetResolutionInfo(res), blankOtherDisplays); #else g_Windowing.SetFullScreen(true, CDisplaySettings::Get().GetResolutionInfo(res), false); @@ -637,11 +650,11 @@ void CGraphicContext::SetScalingResolution(const RESOLUTION_INFO &res, bool need } if(!g_guiSkinzoom) // lookup gui setting if we didn't have it already - g_guiSkinzoom = (CSettingInt*)g_guiSettings.GetSetting("lookandfeel.skinzoom"); + g_guiSkinzoom = (CSettingInt*)CSettings::Get().GetSetting("lookandfeel.skinzoom"); float fZoom = 1.0f; if(g_guiSkinzoom) - fZoom *= (100 + g_guiSkinzoom->GetData()) * 0.01f; + fZoom *= (100 + g_guiSkinzoom->GetValue()) * 0.01f; fZoom -= 1.0f; fToPosX -= fToWidth * fZoom * 0.5f; diff --git a/xbmc/guilib/GraphicContext.h b/xbmc/guilib/GraphicContext.h index 0ce3087d2b729..adbbae41d861e 100644 --- a/xbmc/guilib/GraphicContext.h +++ b/xbmc/guilib/GraphicContext.h @@ -47,6 +47,7 @@ #include "Resolution.h" #include "utils/GlobalsHandling.h" #include "DirtyRegion.h" +#include "settings/ISettingCallback.h" enum VIEW_TYPE { VIEW_TYPE_NONE = 0, VIEW_TYPE_LIST, @@ -62,13 +63,22 @@ enum VIEW_TYPE { VIEW_TYPE_NONE = 0, VIEW_TYPE_AUTO, VIEW_TYPE_MAX }; +enum AdjustRefreshRate +{ + ADJUST_REFRESHRATE_OFF = 0, + ADJUST_REFRESHRATE_ALWAYS, + ADJUST_REFRESHRATE_ON_STARTSTOP +}; -class CGraphicContext : public CCriticalSection +class CGraphicContext : public CCriticalSection, + public ISettingCallback { public: CGraphicContext(void); virtual ~CGraphicContext(void); + virtual void OnSettingChanged(const CSetting *setting); + // the following two functions should wrap any // GL calls to maintain thread safety void BeginPaint(bool lock=true); diff --git a/xbmc/guilib/Key.h b/xbmc/guilib/Key.h index bc1acb8a094dc..960c8e3430fdd 100644 --- a/xbmc/guilib/Key.h +++ b/xbmc/guilib/Key.h @@ -315,6 +315,9 @@ #define ACTION_SWITCH_PLAYER 234 +#define ACTION_SETTINGS_RESET 240 +#define ACTION_SETTINGS_LEVEL_CHANGE 241 + // touch actions #define ACTION_TOUCH_TAP 401 #define ACTION_TOUCH_TAP_TEN 410 diff --git a/xbmc/guilib/TextureBundleXBT.cpp b/xbmc/guilib/TextureBundleXBT.cpp index fa8e8637959ae..ce366c27b7454 100644 --- a/xbmc/guilib/TextureBundleXBT.cpp +++ b/xbmc/guilib/TextureBundleXBT.cpp @@ -25,7 +25,7 @@ #include "GraphicContext.h" #include "utils/log.h" #include "addons/Skin.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "filesystem/SpecialProtocol.h" #include "utils/EndianSwap.h" #include "utils/URIUtils.h" @@ -58,7 +58,7 @@ bool CTextureBundleXBT::OpenBundle() { // if we are the theme bundle, we only load if the user has chosen // a valid theme (or the skin has a default one) - CStdString theme = g_guiSettings.GetString("lookandfeel.skintheme"); + CStdString theme = CSettings::Get().GetString("lookandfeel.skintheme"); if (!theme.IsEmpty() && theme.CompareNoCase("SKINDEFAULT")) { CStdString themeXBT(URIUtils::ReplaceExtension(theme, ".xbt")); diff --git a/xbmc/guilib/TextureBundleXPR.cpp b/xbmc/guilib/TextureBundleXPR.cpp index f9c8aae6f3958..20b50b5877282 100644 --- a/xbmc/guilib/TextureBundleXPR.cpp +++ b/xbmc/guilib/TextureBundleXPR.cpp @@ -30,7 +30,7 @@ #endif #include #include "addons/Skin.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "filesystem/SpecialProtocol.h" #include "utils/EndianSwap.h" #include "utils/URIUtils.h" @@ -125,7 +125,7 @@ bool CTextureBundleXPR::OpenBundle() { // if we are the theme bundle, we only load if the user has chosen // a valid theme (or the skin has a default one) - CStdString theme = g_guiSettings.GetString("lookandfeel.skintheme"); + CStdString theme = CSettings::Get().GetString("lookandfeel.skintheme"); if (!theme.IsEmpty() && theme.CompareNoCase("SKINDEFAULT")) { CStdString themeXPR(URIUtils::ReplaceExtension(theme, ".xpr")); diff --git a/xbmc/input/ButtonTranslator.cpp b/xbmc/input/ButtonTranslator.cpp index 6f71b5347411b..a278aad65f720 100644 --- a/xbmc/input/ButtonTranslator.cpp +++ b/xbmc/input/ButtonTranslator.cpp @@ -220,6 +220,8 @@ static const ActionMapping actions[] = {"volampdown" , ACTION_VOLAMP_DOWN}, {"createbookmark" , ACTION_CREATE_BOOKMARK}, {"createepisodebookmark" , ACTION_CREATE_EPISODE_BOOKMARK}, + {"settingsreset" , ACTION_SETTINGS_RESET}, + {"settingslevelchange", ACTION_SETTINGS_LEVEL_CHANGE}, // PVR actions {"channelup" , ACTION_CHANNEL_UP}, diff --git a/xbmc/input/ButtonTranslator.h b/xbmc/input/ButtonTranslator.h index 6280ae47dc6b8..4b26a9fe0b566 100644 --- a/xbmc/input/ButtonTranslator.h +++ b/xbmc/input/ButtonTranslator.h @@ -30,6 +30,7 @@ #ifdef HAS_EVENT_SERVER #include "network/EventClient.h" #endif +#include "utils/StdString.h" class CKey; class CAction; diff --git a/xbmc/input/MouseStat.cpp b/xbmc/input/MouseStat.cpp index cef30c3907357..954ad1fc373d5 100644 --- a/xbmc/input/MouseStat.cpp +++ b/xbmc/input/MouseStat.cpp @@ -20,8 +20,9 @@ #include "MouseStat.h" #include "guilib/Key.h" -#include "windowing/WindowingFactory.h" +#include "settings/Setting.h" #include "utils/TimeUtils.h" +#include "windowing/WindowingFactory.h" CMouseStat::CMouseStat() { @@ -37,6 +38,16 @@ CMouseStat::~CMouseStat() { } +void CMouseStat::OnSettingChanged(const CSetting *setting) +{ + if (setting == NULL) + return; + + const std::string &settingId = setting->GetId(); + if (settingId == "input.enablemouse") + SetEnabled(((CSettingBool*)setting)->GetValue()); +} + void CMouseStat::Initialize() { // Set the default resolution (PAL) diff --git a/xbmc/input/MouseStat.h b/xbmc/input/MouseStat.h index f6822ea9e44dd..71a70ec81f841 100644 --- a/xbmc/input/MouseStat.h +++ b/xbmc/input/MouseStat.h @@ -21,6 +21,7 @@ * */ +#include "settings/ISettingCallback.h" #include "windowing/XBMC_events.h" #define XBMC_BUTTON(X) (1 << ((X)-1)) @@ -58,13 +59,14 @@ struct MouseState class CAction; -class CMouseStat +class CMouseStat : public ISettingCallback { public: - CMouseStat(); virtual ~CMouseStat(); + virtual void OnSettingChanged(const CSetting *setting); + void Initialize(); void HandleEvent(XBMC_Event& newEvent); void SetResolution(int maxX, int maxY, float speedX, float speedY); diff --git a/xbmc/input/SDLJoystick.cpp b/xbmc/input/SDLJoystick.cpp index ab556fc965f9e..fd8597af47aca 100644 --- a/xbmc/input/SDLJoystick.cpp +++ b/xbmc/input/SDLJoystick.cpp @@ -21,6 +21,7 @@ #include "system.h" #include "SDLJoystick.h" #include "ButtonTranslator.h" +#include "peripherals/devices/PeripheralImon.h" #include "settings/AdvancedSettings.h" #include "utils/log.h" @@ -45,6 +46,16 @@ CJoystick::CJoystick() SetDeadzone(0); } +void CJoystick::OnSettingChanged(const CSetting *setting) +{ + if (setting == NULL) + return; + + const std::string &settingId = setting->GetId(); + if (settingId == "input.enablejoystick") + SetEnabled(((CSettingBool*)setting)->GetValue() && PERIPHERALS::CPeripheralImon::GetCountOfImonsConflictWithDInput() == 0); +} + void CJoystick::Initialize() { if (!IsEnabled()) diff --git a/xbmc/input/SDLJoystick.h b/xbmc/input/SDLJoystick.h index 7bd336c1d80ff..4b07458c1a60e 100644 --- a/xbmc/input/SDLJoystick.h +++ b/xbmc/input/SDLJoystick.h @@ -22,6 +22,7 @@ #define SDL_JOYSTICK_H #include "system.h" // for HAS_SDL_JOYSTICK +#include "settings/ISettingCallback.h" #include #include @@ -45,11 +46,13 @@ // Class to manage all connected joysticks -class CJoystick +class CJoystick : public ISettingCallback { public: CJoystick(); + virtual void OnSettingChanged(const CSetting *setting); + void Initialize(); void Reset(bool axis=false); void ResetAxis(int axisId) { m_Amount[axisId] = 0; } diff --git a/xbmc/input/windows/WINJoystick.cpp b/xbmc/input/windows/WINJoystick.cpp index 293593be0c34c..02dc08c1254ae 100644 --- a/xbmc/input/windows/WINJoystick.cpp +++ b/xbmc/input/windows/WINJoystick.cpp @@ -20,7 +20,9 @@ #include "WINJoystick.h" #include "input/ButtonTranslator.h" +#include "peripherals/devices/PeripheralImon.h" #include "settings/AdvancedSettings.h" +#include "settings/Setting.h" #include "utils/log.h" #include @@ -72,6 +74,16 @@ CJoystick::~CJoystick() ReleaseJoysticks(); } +void CJoystick::OnSettingChanged(const CSetting *setting) +{ + if (setting == NULL) + return; + + const std::string &settingId = setting->GetId(); + if (settingId == "input.enablejoystick") + SetEnabled(((CSettingBool*)setting)->GetValue() && PERIPHERALS::CPeripheralImon::GetCountOfImonsConflictWithDInput() == 0); +} + void CJoystick::ReleaseJoysticks() { CSingleLock lock(m_critSection); diff --git a/xbmc/input/windows/WINJoystick.h b/xbmc/input/windows/WINJoystick.h index f77c96e787f8d..b6da4612eeaac 100644 --- a/xbmc/input/windows/WINJoystick.h +++ b/xbmc/input/windows/WINJoystick.h @@ -21,6 +21,7 @@ #include #include +#include "settings/ISettingCallback.h" #include "threads/CriticalSection.h" #define JACTIVE_BUTTON 0x00000001 @@ -36,12 +37,14 @@ // Class to manage all connected joysticks -class CJoystick +class CJoystick : public ISettingCallback { public: CJoystick(); ~CJoystick(); + virtual void OnSettingChanged(const CSetting *setting); + void Initialize(); void Reset(bool axis=false); void ResetAxis(int axisId) { m_Amount[axisId] = 0; } diff --git a/xbmc/interfaces/Builtins.cpp b/xbmc/interfaces/Builtins.cpp index 660023324a5b3..05b18c7617eb7 100644 --- a/xbmc/interfaces/Builtins.cpp +++ b/xbmc/interfaces/Builtins.cpp @@ -44,6 +44,7 @@ #include "addons/AddonInstaller.h" #include "addons/AddonManager.h" #include "addons/PluginSource.h" +#include "network/NetworkServices.h" #include "utils/log.h" #include "storage/MediaManager.h" #include "utils/RssManager.h" @@ -93,7 +94,8 @@ #endif #include -#include "xbmc/settings/AdvancedSettings.h" +#include "settings/AdvancedSettings.h" +#include "settings/DisplaySettings.h" using namespace std; using namespace XFILE; @@ -835,11 +837,11 @@ int CBuiltins::Execute(const CStdString& execString) { case PLAYLIST_MUSIC: CMediaSettings::Get().SetMusicPlaylistShuffled(g_playlistPlayer.IsShuffled(iPlaylist)); - g_settings.Save(); + CSettings::Get().Save(); break; case PLAYLIST_VIDEO: CMediaSettings::Get().SetVideoPlaylistShuffled(g_playlistPlayer.IsShuffled(iPlaylist)); - g_settings.Save(); + CSettings::Get().Save(); } // send message @@ -879,11 +881,11 @@ int CBuiltins::Execute(const CStdString& execString) { case PLAYLIST_MUSIC: CMediaSettings::Get().SetMusicPlaylistRepeat(state == PLAYLIST::REPEAT_ALL); - g_settings.Save(); + CSettings::Get().Save(); break; case PLAYLIST_VIDEO: CMediaSettings::Get().SetVideoPlaylistRepeat(state == PLAYLIST::REPEAT_ALL); - g_settings.Save(); + CSettings::Get().Save(); } // send messages so now playing window can get updated @@ -1044,7 +1046,7 @@ int CBuiltins::Execute(const CStdString& execString) { int setting = CSkinSettings::Get().TranslateBool(parameter); CSkinSettings::Get().SetBool(setting, !CSkinSettings::Get().GetBool(setting)); - g_settings.Save(); + CSettings::Get().Save(); } else if (execute.Equals("skin.setbool") && params.size()) { @@ -1052,23 +1054,23 @@ int CBuiltins::Execute(const CStdString& execString) { int string = CSkinSettings::Get().TranslateBool(params[0]); CSkinSettings::Get().SetBool(string, params[1].CompareNoCase("true") == 0); - g_settings.Save(); + CSettings::Get().Save(); return 0; } // default is to set it to true int setting = CSkinSettings::Get().TranslateBool(params[0]); CSkinSettings::Get().SetBool(setting, true); - g_settings.Save(); + CSettings::Get().Save(); } else if (execute.Equals("skin.reset")) { CSkinSettings::Get().Reset(parameter); - g_settings.Save(); + CSettings::Get().Save(); } else if (execute.Equals("skin.resetsettings")) { CSkinSettings::Get().Reset(); - g_settings.Save(); + CSettings::Get().Save(); } else if (execute.Equals("skin.theme")) { @@ -1079,11 +1081,11 @@ int CBuiltins::Execute(const CStdString& execString) int iTheme = -1; // find current theme - if (!g_guiSettings.GetString("lookandfeel.skintheme").Equals("SKINDEFAULT")) + if (!StringUtils::EqualsNoCase(CSettings::Get().GetString("lookandfeel.skintheme"), "SKINDEFAULT")) { for (unsigned int i=0;i 1) { @@ -1241,7 +1243,7 @@ int CBuiltins::Execute(const CStdString& execString) if (types.size() > 0 && CGUIWindowAddonBrowser::SelectAddonID(types, result, true) == 1) { CSkinSettings::Get().SetString(string, result); - g_settings.Save(); + CSettings::Get().Save(); } } else if (execute.Equals("dialog.close") && params.size()) @@ -1282,8 +1284,8 @@ int CBuiltins::Execute(const CStdString& execString) CProfilesManager::Get().LoadMasterProfileForLogin(); g_passwordManager.bMasterUser = false; g_windowManager.ActivateWindow(WINDOW_LOGIN_SCREEN); - if (!g_application.StartEventServer()) // event server could be needed in some situations - CGUIDialogKaiToast::QueueNotification("DefaultIconWarning.png", g_localizeStrings.Get(33102), g_localizeStrings.Get(33100)); + if (!CNetworkServices::Get().StartEventServer()) // event server could be needed in some situations + CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Warning, g_localizeStrings.Get(33102), g_localizeStrings.Get(33100)); } else if (execute.Equals("pagedown")) { @@ -1623,8 +1625,8 @@ int CBuiltins::Execute(const CStdString& execString) } else if (execute.Equals("toggledebug")) { - bool debug = g_guiSettings.GetBool("debug.showloginfo"); - g_guiSettings.SetBool("debug.showloginfo", !debug); + bool debug = CSettings::Get().GetBool("debug.showloginfo"); + CSettings::Get().SetBool("debug.showloginfo", !debug); g_advancedSettings.SetDebugMode(!debug); } else if (execute.Equals("startpvrmanager")) diff --git a/xbmc/interfaces/json-rpc/AudioLibrary.cpp b/xbmc/interfaces/json-rpc/AudioLibrary.cpp index e6db52dc0c958..4ecebb88b4892 100644 --- a/xbmc/interfaces/json-rpc/AudioLibrary.cpp +++ b/xbmc/interfaces/json-rpc/AudioLibrary.cpp @@ -32,7 +32,7 @@ #include "ApplicationMessenger.h" #include "filesystem/Directory.h" #include "filesystem/File.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" using namespace MUSIC_INFO; using namespace JSONRPC; @@ -67,7 +67,7 @@ JSONRPC_STATUS CAudioLibrary::GetArtists(const CStdString &method, ITransportLay musicUrl.AddOption("xsp", xsp); } - bool albumArtistsOnly = !g_guiSettings.GetBool("musiclibrary.showcompilationartists"); + bool albumArtistsOnly = !CSettings::Get().GetBool("musiclibrary.showcompilationartists"); if (parameterObject["albumartistsonly"].isBoolean()) albumArtistsOnly = parameterObject["albumartistsonly"].asBoolean(); diff --git a/xbmc/interfaces/json-rpc/GUIOperations.cpp b/xbmc/interfaces/json-rpc/GUIOperations.cpp index 4701e06c18272..0d5518b840d20 100644 --- a/xbmc/interfaces/json-rpc/GUIOperations.cpp +++ b/xbmc/interfaces/json-rpc/GUIOperations.cpp @@ -27,7 +27,7 @@ #include "interfaces/Builtins.h" #include "dialogs/GUIDialogKaiToast.h" #include "addons/AddonManager.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/Variant.h" using namespace std; @@ -111,7 +111,7 @@ JSONRPC_STATUS CGUIOperations::GetPropertyValue(const CStdString &property, CVar result["label"] = g_infoManager.GetLabel(g_infoManager.TranslateString("System.CurrentControl")); else if (property.Equals("skin")) { - CStdString skinId = g_guiSettings.GetString("lookandfeel.skin"); + CStdString skinId = CSettings::Get().GetString("lookandfeel.skin"); AddonPtr addon; CAddonMgr::Get().GetAddon(skinId, addon, ADDON_SKIN); diff --git a/xbmc/interfaces/legacy/Dialog.cpp b/xbmc/interfaces/legacy/Dialog.cpp index fc37d74943e85..0a7dd94576ab2 100644 --- a/xbmc/interfaces/legacy/Dialog.cpp +++ b/xbmc/interfaces/legacy/Dialog.cpp @@ -138,7 +138,7 @@ namespace XBMCAddon std::string mask = maskparam; VECSOURCES *shares = CMediaSourceSettings::Get().GetSources(s_shares); if (!shares) - throw WindowException("Error: GetSourcesFromType given %s is NULL.",s_shares.c_str()); + throw WindowException("Error: GetSources given %s is NULL.",s_shares.c_str()); if (useFileDirectories && (!maskparam.empty() && !maskparam.size() == 0)) mask += "|.rar|.zip"; @@ -162,7 +162,7 @@ namespace XBMCAddon CStdStringArray tmpret; String lmask = mask; if (!shares) - throw WindowException("Error: GetSourcesFromType given %s is NULL.",s_shares.c_str()); + throw WindowException("Error: GetSources given %s is NULL.",s_shares.c_str()); if (useFileDirectories && (!lmask.empty() && !(lmask.size() == 0))) lmask += "|.rar|.zip"; diff --git a/xbmc/interfaces/legacy/ModuleXbmc.cpp b/xbmc/interfaces/legacy/ModuleXbmc.cpp index 25ae23bd17099..ca322d158f7db 100644 --- a/xbmc/interfaces/legacy/ModuleXbmc.cpp +++ b/xbmc/interfaces/legacy/ModuleXbmc.cpp @@ -36,8 +36,6 @@ #include "XTimeUtils.h" #endif #include "guilib/LocalizeStrings.h" -#include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" #include "GUIInfoManager.h" #include "guilib/GUIAudioManager.h" #include "guilib/GUIWindowManager.h" @@ -46,6 +44,8 @@ #include "utils/Crc32.h" #include "FileItem.h" #include "LangInfo.h" +#include "settings/AdvancedSettings.h" +#include "settings/Settings.h" #include "guilib/TextureManager.h" #include "Util.h" #include "URL.h" @@ -178,13 +178,13 @@ namespace XBMCAddon String getSkinDir() { TRACE; - return g_guiSettings.GetString("lookandfeel.skin"); + return CSettings::Get().GetString("lookandfeel.skin"); } String getLanguage(int format /* = CLangCodeExpander::ENGLISH_NAME */, bool region /*= false*/) { TRACE; - CStdString lang = g_guiSettings.GetString("locale.language"); + CStdString lang = CSettings::Get().GetString("locale.language"); switch (format) { diff --git a/xbmc/interfaces/legacy/WindowXML.cpp b/xbmc/interfaces/legacy/WindowXML.cpp index b518fc37d49cb..d906645c2d67d 100644 --- a/xbmc/interfaces/legacy/WindowXML.cpp +++ b/xbmc/interfaces/legacy/WindowXML.cpp @@ -23,7 +23,7 @@ #include "WindowInterceptor.h" #include "guilib/GUIWindowManager.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "addons/Skin.h" #include "filesystem/File.h" #include "utils/URIUtils.h" @@ -518,7 +518,7 @@ namespace XBMCAddon URIUtils::AddSlashAtEnd(pathToLanguageFile); // allocate a bunch of strings - return g_localizeStrings.LoadBlock(m_scriptPath, pathToLanguageFile, g_guiSettings.GetString("locale.language")); + return g_localizeStrings.LoadBlock(m_scriptPath, pathToLanguageFile, CSettings::Get().GetString("locale.language")); } void WindowXML::ClearScriptStrings() diff --git a/xbmc/interfaces/python/XBPython.cpp b/xbmc/interfaces/python/XBPython.cpp index 9fef88a311da2..f23d42a884e70 100644 --- a/xbmc/interfaces/python/XBPython.cpp +++ b/xbmc/interfaces/python/XBPython.cpp @@ -40,6 +40,7 @@ #include "pythreadstate.h" #include "utils/TimeUtils.h" #include "Util.h" +#include "guilib/GraphicContext.h" #include "threads/SystemClock.h" #include "addons/Addon.h" diff --git a/xbmc/linux/HALManager.h b/xbmc/linux/HALManager.h index 48f6e58487e67..e2433a3936a35 100644 --- a/xbmc/linux/HALManager.h +++ b/xbmc/linux/HALManager.h @@ -34,7 +34,6 @@ #include "threads/CriticalSection.h" #include "utils/URIUtils.h" #include "MediaSource.h" -#include "settings/GUISettings.h" class CHALDevice { diff --git a/xbmc/linux/LinuxTimezone.cpp b/xbmc/linux/LinuxTimezone.cpp index 5df42d01b783d..370653feb047d 100644 --- a/xbmc/linux/LinuxTimezone.cpp +++ b/xbmc/linux/LinuxTimezone.cpp @@ -34,6 +34,8 @@ #endif #include "Util.h" +#include "XBDateTime.h" +#include "settings/Settings.h" using namespace std; @@ -145,6 +147,26 @@ CLinuxTimezone::CLinuxTimezone() : m_IsDST(0) free(line); } +void CLinuxTimezone::OnSettingChanged(const CSetting *setting) +{ + if (setting == NULL) + return; + + const std::string &settingId = setting->GetId(); + if (settingId == "locale.timezone") + { + SetTimezone(((CSettingString*)setting)->GetValue()); + + CDateTime::ResetTimezoneBias(); + } + else if (settingId == "locale.timezonecountry") + { + // nothing to do here. Changing locale.timezonecountry will trigger an + // update of locale.timezone and automatically adjust its value + // and execute OnSettingChanged() for it as well (see above) + } +} + vector CLinuxTimezone::GetCounties() { return m_counties; @@ -221,4 +243,28 @@ CStdString CLinuxTimezone::GetOSConfiguredTimezone() return timezoneName; } +void CLinuxTimezone::SettingOptionsTimezoneCountriesFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t) +{ + vector countries = g_timezone.GetCounties(); + for (unsigned int i = 0; i < countries.size(); i++) + list.push_back(make_pair(countries[i], countries[i])); +} + +void CLinuxTimezone::SettingOptionsTimezonesFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t) +{ + current = ((const CSettingString*)setting)->GetValue(); + bool found = false; + vector timezones = g_timezone.GetTimezonesByCountry(CSettings::Get().GetString("locale.timezonecountry")); + for (unsigned int i = 0; i < timezones.size(); i++) + { + if (!found && timezones[i].Equals(current.c_str())) + found = true; + + list.push_back(make_pair(timezones[i], timezones[i])); + } + + if (!found && timezones.size() > 0) + current = timezones[0]; +} + CLinuxTimezone g_timezone; diff --git a/xbmc/linux/LinuxTimezone.h b/xbmc/linux/LinuxTimezone.h index 858bd0a9e8864..e29cb122a20bb 100644 --- a/xbmc/linux/LinuxTimezone.h +++ b/xbmc/linux/LinuxTimezone.h @@ -21,14 +21,20 @@ * */ +#include "settings/ISettingCallback.h" #include "utils/StdString.h" #include #include -class CLinuxTimezone +class CSetting; + +class CLinuxTimezone : public ISettingCallback { public: CLinuxTimezone(); + + virtual void OnSettingChanged(const CSetting *setting); + CStdString GetOSConfiguredTimezone(); std::vector GetCounties(); @@ -37,6 +43,10 @@ class CLinuxTimezone void SetTimezone(CStdString timezone); int m_IsDST; + + static void SettingOptionsTimezoneCountriesFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t); + static void SettingOptionsTimezonesFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t); + private: std::vector m_counties; std::map m_countryByCode; diff --git a/xbmc/linux/OMXClock.cpp b/xbmc/linux/OMXClock.cpp index 38608186b30f2..1b849188a2452 100644 --- a/xbmc/linux/OMXClock.cpp +++ b/xbmc/linux/OMXClock.cpp @@ -27,7 +27,7 @@ #if defined(HAVE_OMXLIB) #include "video/VideoReferenceClock.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "OMXClock.h" #include "utils/MathUtils.h" @@ -318,7 +318,7 @@ bool OMXClock::OMXSetReferenceClock(bool lock /* = true */) OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE refClock; OMX_INIT_STRUCTURE(refClock); - if(g_guiSettings.GetBool("videoplayer.usedisplayasclock") && m_has_video) + if(CSettings::Get().GetBool("videoplayer.usedisplayasclock") && m_has_video) refClock.eClock = OMX_TIME_RefClockVideo; else if(m_has_audio) refClock.eClock = OMX_TIME_RefClockAudio; @@ -761,7 +761,7 @@ bool OMXClock::OMXMediaTime(double pts, bool fixPreroll /* = true*/, bool lock / OMX_INIT_STRUCTURE(timeStamp); timeStamp.nPortIndex = m_omx_clock.GetInputPort(); - if(g_guiSettings.GetBool("videoplayer.usedisplayasclock") && m_has_video) + if(CSettings::Get().GetBool("videoplayer.usedisplayasclock") && m_has_video) index = OMX_IndexConfigTimeCurrentVideoReference; else if(m_has_audio) index = OMX_IndexConfigTimeCurrentAudioReference; diff --git a/xbmc/music/GUIViewStateMusic.cpp b/xbmc/music/GUIViewStateMusic.cpp index 02be182e42afa..a9f2fff1e5541 100644 --- a/xbmc/music/GUIViewStateMusic.cpp +++ b/xbmc/music/GUIViewStateMusic.cpp @@ -21,9 +21,9 @@ #include "GUIViewStateMusic.h" #include "PlayListPlayer.h" #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" @@ -46,8 +46,8 @@ int CGUIViewStateWindowMusic::GetPlaylist() bool CGUIViewStateWindowMusic::AutoPlayNextItem() { - return g_guiSettings.GetBool("musicplayer.autoplaynextitem") && - !g_guiSettings.GetBool("musicplayer.queuebydefault"); + return CSettings::Get().GetBool("musicplayer.autoplaynextitem") && + !CSettings::Get().GetBool("musicplayer.queuebydefault"); } CStdString CGUIViewStateWindowMusic::GetLockType() @@ -68,12 +68,12 @@ VECSOURCES& CGUIViewStateWindowMusic::GetSources() CGUIViewStateMusicSearch::CGUIViewStateMusicSearch(const CFileItemList& items) : CGUIViewStateWindowMusic(items) { - CStdString strTrackLeft=g_guiSettings.GetString("musicfiles.librarytrackformat"); + CStdString strTrackLeft=CSettings::Get().GetString("musicfiles.librarytrackformat"); if (strTrackLeft.IsEmpty()) - strTrackLeft = g_guiSettings.GetString("musicfiles.trackformat"); - CStdString strTrackRight=g_guiSettings.GetString("musicfiles.librarytrackformatright"); + strTrackLeft = CSettings::Get().GetString("musicfiles.trackformat"); + CStdString strTrackRight=CSettings::Get().GetString("musicfiles.librarytrackformatright"); if (strTrackRight.IsEmpty()) - strTrackRight = g_guiSettings.GetString("musicfiles.trackformatright"); + strTrackRight = CSettings::Get().GetString("musicfiles.trackformatright"); CStdString strAlbumLeft = g_advancedSettings.m_strMusicLibraryAlbumFormat; if (strAlbumLeft.IsEmpty()) @@ -82,7 +82,7 @@ CGUIViewStateMusicSearch::CGUIViewStateMusicSearch(const CFileItemList& items) : if (strAlbumRight.IsEmpty()) strAlbumRight = "%A"; // artist - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) { AddSortMethod(SORT_METHOD_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T - %A", "%D", "%L", "%A")); // Title, Artist, Duration| empty, empty SetSortMethod(SORT_METHOD_TITLE_IGNORE_THE); @@ -93,7 +93,7 @@ CGUIViewStateMusicSearch::CGUIViewStateMusicSearch(const CFileItemList& items) : SetSortMethod(SORT_METHOD_TITLE); } - CViewState *viewState = CViewStateSettings::Get().Get("musicnavsongs"); + const CViewState *viewState = CViewStateSettings::Get().Get("musicnavsongs"); SetViewAsControl(viewState->m_viewMode); SetSortOrder(viewState->m_sortOrder); @@ -110,12 +110,12 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item CMusicDatabaseDirectory dir; NODE_TYPE NodeType=dir.GetDirectoryChildType(items.GetPath()); - CStdString strTrackLeft=g_guiSettings.GetString("musicfiles.librarytrackformat"); + CStdString strTrackLeft=CSettings::Get().GetString("musicfiles.librarytrackformat"); if (strTrackLeft.IsEmpty()) - strTrackLeft = g_guiSettings.GetString("musicfiles.trackformat"); - CStdString strTrackRight=g_guiSettings.GetString("musicfiles.librarytrackformatright"); + strTrackLeft = CSettings::Get().GetString("musicfiles.trackformat"); + CStdString strTrackRight=CSettings::Get().GetString("musicfiles.librarytrackformatright"); if (strTrackRight.IsEmpty()) - strTrackRight = g_guiSettings.GetString("musicfiles.trackformatright"); + strTrackRight = CSettings::Get().GetString("musicfiles.trackformatright"); CStdString strAlbumLeft = g_advancedSettings.m_strMusicLibraryAlbumFormat; if (strAlbumLeft.IsEmpty()) @@ -171,7 +171,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item break; case NODE_TYPE_ARTIST: { - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) { AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 557, LABEL_MASKS("%F", "", "%A", "")); // Filename, empty | Artist, empty SetSortMethod(SORT_METHOD_ARTIST_IGNORE_THE); @@ -181,8 +181,8 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item AddSortMethod(SORT_METHOD_ARTIST, 557, LABEL_MASKS("%F", "", "%A", "")); // Filename, empty | Artist, empty SetSortMethod(SORT_METHOD_ARTIST); } - - CViewState *viewState = CViewStateSettings::Get().Get("musicnavartists"); + + const CViewState *viewState = CViewStateSettings::Get().Get("musicnavartists"); SetViewAsControl(viewState->m_viewMode); SetSortOrder(viewState->m_sortOrder); } @@ -192,13 +192,13 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item case NODE_TYPE_YEAR_ALBUM: { // album - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined else AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined // artist - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 557, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined else AddSortMethod(SORT_METHOD_ARTIST, 557, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined @@ -206,7 +206,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item // year AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); - CViewState *viewState = CViewStateSettings::Get().Get("musicnavalbums"); + const CViewState *viewState = CViewStateSettings::Get().Get("musicnavalbums"); SetSortMethod(viewState->m_sortMethod); SetViewAsControl(viewState->m_viewMode); SetSortOrder(viewState->m_sortOrder); @@ -258,13 +258,12 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item SetSortMethod(SORT_METHOD_NONE); SetViewAsControl(DEFAULT_VIEW_LIST); - SetSortOrder(SortOrderNone); } break; case NODE_TYPE_SINGLES: { - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) { AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 557, LABEL_MASKS("%A - %T", "%D")); // Artist, Title, Duration| empty, empty AddSortMethod(SORT_METHOD_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T - %A", "%D")); // Title, Artist, Duration| empty, empty @@ -278,8 +277,8 @@ 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 - - CViewState *viewState = CViewStateSettings::Get().Get("musicnavsongs"); + + const CViewState *viewState = CViewStateSettings::Get().Get("musicnavsongs"); SetSortMethod(viewState->m_sortMethod); SetViewAsControl(viewState->m_viewMode); SetSortOrder(viewState->m_sortOrder); @@ -291,7 +290,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item case NODE_TYPE_SONG: { AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined| empty, empty - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) { AddSortMethod(SORT_METHOD_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T - %A", "%D")); // Title, Artist, Duration| empty, empty AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%B - %T - %A", "%D")); // Album, Title, Artist, Duration| empty, empty @@ -308,12 +307,12 @@ 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"); + + const 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); + SetSortMethod(CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SORT_METHOD_ALBUM_IGNORE_THE : SORT_METHOD_ALBUM); else SetSortMethod(viewState->m_sortMethod); @@ -382,11 +381,11 @@ CGUIViewStateMusicSmartPlaylist::CGUIViewStateMusicSmartPlaylist(const CFileItem { if (items.GetContent() == "songs" || items.GetContent() == "mixed") { - CStdString strTrackLeft=g_guiSettings.GetString("musicfiles.trackformat"); - CStdString strTrackRight=g_guiSettings.GetString("musicfiles.trackformatright"); + CStdString strTrackLeft=CSettings::Get().GetString("musicfiles.trackformat"); + CStdString strTrackRight=CSettings::Get().GetString("musicfiles.trackformatright"); AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined| empty, empty - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) { AddSortMethod(SORT_METHOD_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T - %A", "%D")); // Title, Artist, Duration| empty, empty AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%B - %T - %A", "%D")); // Album, Titel, Artist, Duration| empty, empty @@ -416,13 +415,13 @@ CGUIViewStateMusicSmartPlaylist::CGUIViewStateMusicSmartPlaylist(const CFileItem strAlbumRight = "%A"; // artist // album - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined else AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined // artist - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 557, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined else AddSortMethod(SORT_METHOD_ARTIST, 557, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined @@ -449,12 +448,12 @@ void CGUIViewStateMusicSmartPlaylist::SaveViewState() CGUIViewStateMusicPlaylist::CGUIViewStateMusicPlaylist(const CFileItemList& items) : CGUIViewStateWindowMusic(items) { - CStdString strTrackLeft=g_guiSettings.GetString("musicfiles.trackformat"); - CStdString strTrackRight=g_guiSettings.GetString("musicfiles.trackformatright"); + CStdString strTrackLeft=CSettings::Get().GetString("musicfiles.trackformat"); + CStdString strTrackRight=CSettings::Get().GetString("musicfiles.trackformatright"); AddSortMethod(SORT_METHOD_PLAYLIST_ORDER, 559, LABEL_MASKS(strTrackLeft, strTrackRight)); AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined| empty, empty - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) { AddSortMethod(SORT_METHOD_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T - %A", "%D")); // Title, Artist, Duration| empty, empty AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%B - %T - %A", "%D")); // Album, Titel, Artist, Duration| empty, empty @@ -472,7 +471,8 @@ 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); - CViewState *viewState = CViewStateSettings::Get().Get("musicfiles"); + + const CViewState *viewState = CViewStateSettings::Get().Get("musicfiles"); SetViewAsControl(viewState->m_viewMode); SetSortOrder(viewState->m_sortOrder); @@ -498,18 +498,18 @@ CGUIViewStateWindowMusicNav::CGUIViewStateWindowMusicNav(const CFileItemList& it } else { - if (items.IsVideoDb() && items.Size() > (g_guiSettings.GetBool("filelists.showparentdiritems")?1:0)) + if (items.IsVideoDb() && items.Size() > (CSettings::Get().GetBool("filelists.showparentdiritems")?1:0)) { XFILE::VIDEODATABASEDIRECTORY::CQueryParams params; - XFILE::CVideoDatabaseDirectory::GetQueryParams(items[g_guiSettings.GetBool("filelists.showparentdiritems")?1:0]->GetPath(),params); + XFILE::CVideoDatabaseDirectory::GetQueryParams(items[CSettings::Get().GetBool("filelists.showparentdiritems")?1:0]->GetPath(),params); if (params.GetMVideoId() != -1) { - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%T", "%Y")); // Filename, Duration | Foldername, empty else AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", "%Y")); // Filename, Duration | Foldername, empty AddSortMethod(SORT_METHOD_YEAR,562, LABEL_MASKS("%T", "%Y")); - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) { AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE,557, LABEL_MASKS("%A - %T", "%Y")); AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE,558, LABEL_MASKS("%B - %T", "%Y")); @@ -519,8 +519,8 @@ CGUIViewStateWindowMusicNav::CGUIViewStateWindowMusicNav(const CFileItemList& it AddSortMethod(SORT_METHOD_ARTIST,557, LABEL_MASKS("%A - %T", "%Y")); AddSortMethod(SORT_METHOD_ALBUM,558, LABEL_MASKS("%B - %T", "%Y")); } - CStdString strTrackLeft=g_guiSettings.GetString("musicfiles.trackformat"); - CStdString strTrackRight=g_guiSettings.GetString("musicfiles.trackformatright"); + CStdString strTrackLeft=CSettings::Get().GetString("musicfiles.trackformat"); + CStdString strTrackRight=CSettings::Get().GetString("musicfiles.trackformatright"); AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined| empty, empty } else @@ -628,10 +628,10 @@ CGUIViewStateWindowMusicSongs::CGUIViewStateWindowMusicSongs(const CFileItemList } else { - CStdString strTrackLeft=g_guiSettings.GetString("musicfiles.trackformat"); - CStdString strTrackRight=g_guiSettings.GetString("musicfiles.trackformatright"); + CStdString strTrackLeft=CSettings::Get().GetString("musicfiles.trackformat"); + CStdString strTrackRight=CSettings::Get().GetString("musicfiles.trackformatright"); - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS(strTrackLeft, strTrackRight, "%L", "")); // Userdefined, Userdefined | FolderName, empty else AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS(strTrackLeft, strTrackRight, "%L", "")); // Userdefined, Userdefined | FolderName, empty @@ -640,8 +640,8 @@ 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")); - - CViewState *viewState = CViewStateSettings::Get().Get("musicfiles"); + + const CViewState *viewState = CViewStateSettings::Get().Get("musicfiles"); SetSortMethod(viewState->m_sortMethod); SetViewAsControl(viewState->m_viewMode); SetSortOrder(viewState->m_sortOrder); @@ -663,12 +663,12 @@ VECSOURCES& CGUIViewStateWindowMusicSongs::GetSources() CGUIViewStateWindowMusicPlaylist::CGUIViewStateWindowMusicPlaylist(const CFileItemList& items) : CGUIViewStateWindowMusic(items) { - CStdString strTrackLeft=g_guiSettings.GetString("musicfiles.nowplayingtrackformat"); + CStdString strTrackLeft=CSettings::Get().GetString("musicfiles.nowplayingtrackformat"); if (strTrackLeft.IsEmpty()) - strTrackLeft = g_guiSettings.GetString("musicfiles.trackformat"); - CStdString strTrackRight=g_guiSettings.GetString("musicfiles.nowplayingtrackformatright"); + strTrackLeft = CSettings::Get().GetString("musicfiles.trackformat"); + CStdString strTrackRight=CSettings::Get().GetString("musicfiles.nowplayingtrackformatright"); if (strTrackRight.IsEmpty()) - strTrackRight = g_guiSettings.GetString("musicfiles.trackformatright"); + strTrackRight = CSettings::Get().GetString("musicfiles.trackformatright"); AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS(strTrackLeft, strTrackRight, "%L", "")); // Userdefined, Userdefined | FolderName, empty SetSortMethod(SORT_METHOD_NONE); diff --git a/xbmc/music/MusicDatabase.cpp b/xbmc/music/MusicDatabase.cpp index d30cdad6f8962..68fe06f6950e0 100644 --- a/xbmc/music/MusicDatabase.cpp +++ b/xbmc/music/MusicDatabase.cpp @@ -44,8 +44,6 @@ #include "dialogs/GUIDialogSelect.h" #include "filesystem/File.h" #include "profiles/ProfilesManager.h" -#include "settings/MediaSettings.h" -#include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" #include "FileItem.h" #include "Application.h" @@ -53,6 +51,7 @@ #include "karaoke/karaokelyricsfactory.h" #endif #include "storage/MediaManager.h" +#include "settings/MediaSettings.h" #include "settings/Settings.h" #include "utils/StringUtils.h" #include "guilib/LocalizeStrings.h" @@ -2408,7 +2407,7 @@ void CMusicDatabase::DeleteAlbumInfo() bool CMusicDatabase::LookupCDDBInfo(bool bRequery/*=false*/) { #ifdef HAS_DVD_DRIVE - if (!g_guiSettings.GetBool("audiocds.usecddb")) + if (!CSettings::Get().GetBool("audiocds.usecddb")) return false; // check network connectivity @@ -2508,7 +2507,7 @@ bool CMusicDatabase::LookupCDDBInfo(bool bRequery/*=false*/) } // if ( !cddb.queryCDinfo( pCdInfo ) ) else pDialogProgress->Close(); - } // if (pCdInfo->HasCDDBInfo() && g_settings.m_bUseCDDB) + } // Filling the file items with cddb info happens in CMusicInfoTagLoaderCDDA @@ -3673,7 +3672,7 @@ bool CMusicDatabase::UpdateOldVersion(int version) m_pDS->exec("DROP TABLE thumb"); CMediaSettings::Get().SetMusicNeedsUpdate(27); - g_settings.Save(); + CSettings::Get().Save(); } if (version < 29) @@ -4496,7 +4495,7 @@ bool CMusicDatabase::GetItems(const CStdString &strBaseDir, const CStdString &it else if (itemType.Equals("years")) return GetYearsNav(strBaseDir, items, filter); else if (itemType.Equals("artists")) - return GetArtistsNav(strBaseDir, items, !g_guiSettings.GetBool("musiclibrary.showcompilationartists"), -1, -1, -1, filter, sortDescription); + return GetArtistsNav(strBaseDir, items, !CSettings::Get().GetBool("musiclibrary.showcompilationartists"), -1, -1, -1, filter, sortDescription); else if (itemType.Equals("albums")) return GetAlbumsByWhere(strBaseDir, filter, items, sortDescription); else if (itemType.Equals("songs")) @@ -5538,7 +5537,7 @@ bool CMusicDatabase::GetFilter(CDbUrl &musicUrl, Filter &filter, SortDescription if (xsp.GetOrder() != SortByNone) sorting.sortBy = xsp.GetOrder(); sorting.sortOrder = xsp.GetOrderAscending() ? SortOrderAscending : SortOrderDescending; - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) sorting.sortAttributes = SortAttributeIgnoreArticle; } } diff --git a/xbmc/music/MusicInfoLoader.cpp b/xbmc/music/MusicInfoLoader.cpp index 118cc524f5498..4cb41c2f6c959 100644 --- a/xbmc/music/MusicInfoLoader.cpp +++ b/xbmc/music/MusicInfoLoader.cpp @@ -29,7 +29,7 @@ #include "utils/URIUtils.h" #include "music/tags/MusicInfoTag.h" #include "filesystem/File.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "FileItem.h" #include "utils/log.h" #include "Artist.h" @@ -173,7 +173,7 @@ bool CMusicInfoLoader::LoadItem(CFileItem* pItem) pItem->SetArt("thumb", song.strThumb); } } - else if (g_guiSettings.GetBool("musicfiles.usetags") || pItem->IsCDDA()) + else if (CSettings::Get().GetBool("musicfiles.usetags") || pItem->IsCDDA()) { // Nothing found, load tag from file, // always try to load cddb info // get correct tag parser diff --git a/xbmc/music/dialogs/GUIDialogMusicInfo.cpp b/xbmc/music/dialogs/GUIDialogMusicInfo.cpp index e4a6717e7b26d..84bd0b2fc2a7f 100644 --- a/xbmc/music/dialogs/GUIDialogMusicInfo.cpp +++ b/xbmc/music/dialogs/GUIDialogMusicInfo.cpp @@ -32,8 +32,8 @@ #include "storage/MediaManager.h" #include "utils/AsyncFileCopy.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" #include "settings/MediaSourceSettings.h" +#include "settings/Settings.h" #include "guilib/Key.h" #include "guilib/LocalizeStrings.h" #include "utils/log.h" @@ -494,7 +494,7 @@ void CGUIDialogMusicInfo::OnGetFanart() } CStdString result; - VECSOURCES sources(*CMediaSourceSettings::Get().GetSources("music")); + 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/GUIDialogMusicOSD.cpp b/xbmc/music/dialogs/GUIDialogMusicOSD.cpp index e3ae7ad01d606..a517a57588f21 100644 --- a/xbmc/music/dialogs/GUIDialogMusicOSD.cpp +++ b/xbmc/music/dialogs/GUIDialogMusicOSD.cpp @@ -24,7 +24,6 @@ #include "input/MouseStat.h" #include "GUIUserMessages.h" #include "settings/Settings.h" -#include "settings/GUISettings.h" #include "addons/GUIWindowAddonBrowser.h" #define CONTROL_VIS_BUTTON 500 @@ -52,8 +51,8 @@ bool CGUIDialogMusicOSD::OnMessage(CGUIMessage &message) CStdString addonID; if (CGUIWindowAddonBrowser::SelectAddonID(ADDON::ADDON_VIZ, addonID, true) == 1) { - g_guiSettings.SetString("musicplayer.visualisation", addonID); - g_settings.Save(); + CSettings::Get().SetString("musicplayer.visualisation", addonID); + CSettings::Get().Save(); g_windowManager.SendMessage(GUI_MSG_VISUALISATION_RELOAD, 0, 0); } } diff --git a/xbmc/music/dialogs/GUIDialogSongInfo.cpp b/xbmc/music/dialogs/GUIDialogSongInfo.cpp index de70532961279..8cc53c8f6ba93 100644 --- a/xbmc/music/dialogs/GUIDialogSongInfo.cpp +++ b/xbmc/music/dialogs/GUIDialogSongInfo.cpp @@ -33,8 +33,8 @@ #include "filesystem/CurlFile.h" #include "FileItem.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" #include "settings/MediaSourceSettings.h" +#include "settings/Settings.h" #include "guilib/LocalizeStrings.h" #include "TextureCache.h" #include "music/Album.h" diff --git a/xbmc/music/infoscanner/MusicInfoScanner.cpp b/xbmc/music/infoscanner/MusicInfoScanner.cpp index 4dc705d661a7a..7b7c473130e9b 100644 --- a/xbmc/music/infoscanner/MusicInfoScanner.cpp +++ b/xbmc/music/infoscanner/MusicInfoScanner.cpp @@ -39,7 +39,7 @@ #include "filesystem/File.h" #include "filesystem/Directory.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "FileItem.h" #include "guilib/LocalizeStrings.h" #include "utils/StringUtils.h" @@ -86,7 +86,7 @@ void CMusicInfoScanner::Process() m_musicDatabase.Open(); - if (m_showDialog && !g_guiSettings.GetBool("musiclibrary.backgroundupdate")) + if (m_showDialog && !CSettings::Get().GetBool("musiclibrary.backgroundupdate")) { CGUIDialogExtendedProgressBar* dialog = (CGUIDialogExtendedProgressBar*)g_windowManager.GetWindow(WINDOW_DIALOG_EXT_PROGRESS); @@ -1182,7 +1182,7 @@ INFO_RET CMusicInfoScanner::DownloadAlbumInfo(const CAlbum& album, ADDON::Scrape CLog::Log(LOGERROR,"Unable to find an url in nfo file: %s", strNfo.c_str()); } - if (!scraper.CheckValidOrFallback(g_guiSettings.GetString("musiclibrary.albumsscraper"))) + if (!scraper.CheckValidOrFallback(CSettings::Get().GetString("musiclibrary.albumsscraper"))) { // the current scraper is invalid, as is the default - bail CLog::Log(LOGERROR, "%s - current and default scrapers are invalid. Pick another one", __FUNCTION__); return INFO_ERROR; diff --git a/xbmc/music/karaoke/karaokelyricsmanager.cpp b/xbmc/music/karaoke/karaokelyricsmanager.cpp index 9801bc4add32d..4c856a551d841 100644 --- a/xbmc/music/karaoke/karaokelyricsmanager.cpp +++ b/xbmc/music/karaoke/karaokelyricsmanager.cpp @@ -23,7 +23,7 @@ #include "threads/SystemClock.h" #include "Application.h" #include "guilib/GUIWindowManager.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "karaokelyrics.h" #include "karaokelyricsfactory.h" @@ -64,7 +64,7 @@ bool CKaraokeLyricsManager::Start(const CStdString & strSongPath) Stop(); // shouldn't happen, but... // If disabled by configuration, do nothing - if ( !g_guiSettings.GetBool("karaoke.enabled") ) + if ( !CSettings::Get().GetBool("karaoke.enabled") ) return false; m_Lyrics = CKaraokeLyricsFactory::CreateLyrics( strSongPath ); @@ -144,7 +144,7 @@ void CKaraokeLyricsManager::ProcessSlow() return; } - if ( !m_karaokeSongPlayed || !g_guiSettings.GetBool("karaoke.autopopupselector") ) + if ( !m_karaokeSongPlayed || !CSettings::Get().GetBool("karaoke.autopopupselector") ) return; // If less than 750ms passed return; we're still processing STOP events diff --git a/xbmc/music/karaoke/karaokelyricstext.cpp b/xbmc/music/karaoke/karaokelyricstext.cpp index 64d2e45335925..661c3d6c3eef1 100644 --- a/xbmc/music/karaoke/karaokelyricstext.cpp +++ b/xbmc/music/karaoke/karaokelyricstext.cpp @@ -24,7 +24,7 @@ #include "utils/CharsetConverter.h" #include "settings/DisplaySettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "guilib/GUITextLayout.h" #include "guilib/GUIFont.h" #include "karaokelyricstext.h" @@ -68,7 +68,7 @@ CKaraokeLyricsText::CKaraokeLyricsText() m_preambleLayout = 0; m_karaokeFont = 0; - int coloridx = g_guiSettings.GetInt("karaoke.fontcolors"); + int coloridx = CSettings::Get().GetInt("karaoke.fontcolors"); if ( coloridx < KARAOKE_COLOR_START || coloridx >= KARAOKE_COLOR_END ) coloridx = 0; @@ -139,11 +139,11 @@ bool CKaraokeLyricsText::InitGraphics() if ( m_lyrics.empty() ) return false; - CStdString fontPath = "special://xbmc/media/Fonts/" + g_guiSettings.GetString("karaoke.font"); + CStdString fontPath = "special://xbmc/media/Fonts/" + CSettings::Get().GetString("karaoke.font"); m_karaokeFont = g_fontManager.LoadTTF("__karaoke__", fontPath, - m_colorLyrics, 0, g_guiSettings.GetInt("karaoke.fontheight"), FONT_STYLE_BOLD ); + m_colorLyrics, 0, CSettings::Get().GetInt("karaoke.fontheight"), FONT_STYLE_BOLD ); CGUIFont *karaokeBorder = g_fontManager.LoadTTF("__karaokeborder__", fontPath, - m_colorLyrics, 0, g_guiSettings.GetInt("karaoke.fontheight"), FONT_STYLE_BOLD, true ); + m_colorLyrics, 0, CSettings::Get().GetInt("karaoke.fontheight"), FONT_STYLE_BOLD, true ); if ( !m_karaokeFont ) { diff --git a/xbmc/music/karaoke/karaokelyricstext.h b/xbmc/music/karaoke/karaokelyricstext.h index cc402c4b73c17..d9237b220a544 100644 --- a/xbmc/music/karaoke/karaokelyricstext.h +++ b/xbmc/music/karaoke/karaokelyricstext.h @@ -25,6 +25,15 @@ #include "karaokelyrics.h" +// Karaoke colours +// If you want to add more colors, it should be done the following way: +// 1. Increase KARAOKE_COLOR_END +// 2. Add a new color description in language/English/strings.xml in block +// with id 22040 + KARAOKE_COLOR_END value +// 3. Add a new color hex mask into gLyricColors structure in karaoke/karaokelyricstext.cpp +#define KARAOKE_COLOR_START 0 +#define KARAOKE_COLOR_END 4 + class CGUITextLayout; class CGUIFont; diff --git a/xbmc/music/karaoke/karaokelyricstextkar.cpp b/xbmc/music/karaoke/karaokelyricstextkar.cpp index 25ec01a9ccae6..efc4ea3d13250 100644 --- a/xbmc/music/karaoke/karaokelyricstextkar.cpp +++ b/xbmc/music/karaoke/karaokelyricstextkar.cpp @@ -22,7 +22,7 @@ #include "utils/CharsetConverter.h" #include "filesystem/File.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/log.h" #include @@ -600,10 +600,10 @@ CStdString CKaraokeLyricsTextKAR::convertText( const char * data ) CStdString strUTF8; // Use some heuristics; need to replace by real detection stuff later - if ( g_charsetConverter.isValidUtf8(data) || g_guiSettings.GetString("karaoke.charset") == "DEFAULT" ) + if ( g_charsetConverter.isValidUtf8(data) || CSettings::Get().GetString("karaoke.charset") == "DEFAULT" ) strUTF8 = data; else - g_charsetConverter.stringCharsetToUtf8( g_guiSettings.GetString("karaoke.charset"), data, strUTF8 ); + g_charsetConverter.stringCharsetToUtf8( CSettings::Get().GetString("karaoke.charset"), data, strUTF8 ); if ( strUTF8.size() == 0 ) strUTF8 = " "; diff --git a/xbmc/music/tags/MusicInfoTag.h b/xbmc/music/tags/MusicInfoTag.h index a4ea3baf4f100..9a5525e2a1a8b 100644 --- a/xbmc/music/tags/MusicInfoTag.h +++ b/xbmc/music/tags/MusicInfoTag.h @@ -38,6 +38,13 @@ class CArtist; #define REPLAY_GAIN_HAS_TRACK_PEAK 4 #define REPLAY_GAIN_HAS_ALBUM_PEAK 8 +enum ReplayGain +{ + REPLAY_GAIN_NONE = 0, + REPLAY_GAIN_ALBUM, + REPLAY_GAIN_TRACK +}; + namespace MUSIC_INFO { class EmbeddedArtInfo diff --git a/xbmc/music/windows/GUIWindowMusicBase.cpp b/xbmc/music/windows/GUIWindowMusicBase.cpp index 2f4c974e68b72..f53df365eeb8f 100644 --- a/xbmc/music/windows/GUIWindowMusicBase.cpp +++ b/xbmc/music/windows/GUIWindowMusicBase.cpp @@ -55,10 +55,9 @@ #include "filesystem/File.h" #include "profiles/ProfilesManager.h" #include "storage/MediaManager.h" -#include "settings/Settings.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" #include "settings/MediaSettings.h" +#include "settings/Settings.h" #include "guilib/LocalizeStrings.h" #include "utils/TimeUtils.h" #include "utils/log.h" @@ -146,10 +145,10 @@ bool CGUIWindowMusicBase::OnMessage(CGUIMessage& message) // save current window, unless the current window is the music playlist window if (GetID() != WINDOW_MUSIC_PLAYLIST && - g_guiSettings.GetInt("mymusic.startwindow") != GetID()) + CSettings::Get().GetInt("mymusic.startwindow") != GetID()) { - g_guiSettings.SetInt("mymusic.startwindow", GetID()); - g_settings.Save(); + CSettings::Get().SetInt("mymusic.startwindow", GetID()); + CSettings::Get().Save(); } return true; @@ -175,11 +174,11 @@ bool CGUIWindowMusicBase::OnMessage(CGUIMessage& message) if (nWindow == GetID()) return true; - g_guiSettings.SetInt("mymusic.startwindow", nWindow); - g_settings.Save(); + CSettings::Get().SetInt("mymusic.startwindow", nWindow); + CSettings::Get().Save(); g_windowManager.ChangeActiveWindow(nWindow); - CGUIMessage msg2(GUI_MSG_SETFOCUS, g_guiSettings.GetInt("mymusic.startwindow"), CONTROL_BTNTYPE); + CGUIMessage msg2(GUI_MSG_SETFOCUS, CSettings::Get().GetInt("mymusic.startwindow"), CONTROL_BTNTYPE); g_windowManager.SendMessage(msg2); return true; @@ -207,7 +206,7 @@ bool CGUIWindowMusicBase::OnMessage(CGUIMessage& message) // or be at the files window and have file deletion enabled else if (GetID() == WINDOW_MUSIC_FILES && - g_guiSettings.GetBool("filelists.allowfiledeletion")) + CSettings::Get().GetBool("filelists.allowfiledeletion")) { OnDeleteItem(iItem); } @@ -669,7 +668,7 @@ void CGUIWindowMusicBase::UpdateButtons() g_windowManager.SendMessage(msg2); // Select the current window as default item - CONTROL_SELECT_ITEM(CONTROL_BTNTYPE, g_guiSettings.GetInt("mymusic.startwindow") - WINDOW_MUSIC_FILES); + CONTROL_SELECT_ITEM(CONTROL_BTNTYPE, CSettings::Get().GetInt("mymusic.startwindow") - WINDOW_MUSIC_FILES); CGUIMediaWindow::UpdateButtons(); } @@ -959,7 +958,7 @@ bool CGUIWindowMusicBase::OnPlayMedia(int iItem) // turned on, but we still want to use the playlist player in order to handle more queued items // following etc. // Karaoke items also can be added in runtime (while the song is played), so it should be queued too. - if ( (g_guiSettings.GetBool("musicplayer.queuebydefault") && g_windowManager.GetActiveWindow() != WINDOW_MUSIC_PLAYLIST_EDITOR) + if ( (CSettings::Get().GetBool("musicplayer.queuebydefault") && g_windowManager.GetActiveWindow() != WINDOW_MUSIC_PLAYLIST_EDITOR) || pItem->IsKaraoke() ) { // TODO: Should the playlist be cleared if nothing is already playing? @@ -1043,7 +1042,7 @@ void CGUIWindowMusicBase::UpdateThumb(const CAlbum &album, const CStdString &pat void CGUIWindowMusicBase::OnRetrieveMusicInfo(CFileItemList& items) { if (items.GetFolderCount()==items.Size() || items.IsMusicDb() || - (!g_guiSettings.GetBool("musicfiles.usetags") && !items.IsCDDA())) + (!CSettings::Get().GetBool("musicfiles.usetags") && !items.IsCDDA())) { return; } @@ -1151,7 +1150,7 @@ void CGUIWindowMusicBase::OnInitWindow() { g_application.StartMusicScan("", CMusicInfoScanner::SCAN_RESCAN); CMediaSettings::Get().SetMusicNeedsUpdate(0); // once is enough (user may interrupt, but that's up to them) - g_settings.Save(); + CSettings::Get().Save(); } } } diff --git a/xbmc/music/windows/GUIWindowMusicBase.h b/xbmc/music/windows/GUIWindowMusicBase.h index 8050baaa34f65..2b86799f07183 100644 --- a/xbmc/music/windows/GUIWindowMusicBase.h +++ b/xbmc/music/windows/GUIWindowMusicBase.h @@ -100,7 +100,7 @@ class CGUIWindowMusicBase : public CGUIMediaWindow typedef std::vector ::iterator ivecItems; ///< CFileItem* vector Iterator CGUIDialogProgress* m_dlgProgress; ///< Progress dialog - // member variables to save frequently used g_guiSettings (which is slow) + // member variables to save frequently used CSettings (which is slow) bool m_hideExtensions; CMusicDatabase m_musicdatabase; MUSIC_INFO::CMusicInfoLoader m_musicInfoLoader; diff --git a/xbmc/music/windows/GUIWindowMusicNav.cpp b/xbmc/music/windows/GUIWindowMusicNav.cpp index e4bd8b5060445..9442a2f944489 100644 --- a/xbmc/music/windows/GUIWindowMusicNav.cpp +++ b/xbmc/music/windows/GUIWindowMusicNav.cpp @@ -46,7 +46,6 @@ #include "ApplicationMessenger.h" #include "settings/Settings.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" #include "guilib/LocalizeStrings.h" #include "utils/log.h" #include "utils/StringUtils.h" @@ -103,7 +102,7 @@ bool CGUIWindowMusicNav::OnMessage(CGUIMessage& message) // is this the first time the window is opened? if (m_vecItems->GetPath() == "?" && message.GetStringParam().IsEmpty()) - message.SetStringParam(g_guiSettings.GetString("mymusic.defaultlibview")); + message.SetStringParam(CSettings::Get().GetString("mymusic.defaultlibview")); DisplayEmptyDatabaseMessage(false); // reset message state @@ -477,9 +476,9 @@ void CGUIWindowMusicNav::GetContextButtons(int itemNumber, CContextButtons &butt nodetype == NODE_TYPE_OVERVIEW || nodetype == NODE_TYPE_TOP100)) { - if (!item->GetPath().Equals(g_guiSettings.GetString("mymusic.defaultlibview"))) + if (!item->GetPath().Equals(CSettings::Get().GetString("mymusic.defaultlibview").c_str())) buttons.Add(CONTEXT_BUTTON_SET_DEFAULT, 13335); // set default - if (strcmp(g_guiSettings.GetString("mymusic.defaultlibview"), "")) + if (strcmp(CSettings::Get().GetString("mymusic.defaultlibview").c_str(), "")) buttons.Add(CONTEXT_BUTTON_CLEAR_DEFAULT, 13403); // clear default } NODE_TYPE childtype = dir.GetDirectoryChildType(item->GetPath()); @@ -616,13 +615,13 @@ bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) } case CONTEXT_BUTTON_SET_DEFAULT: - g_guiSettings.SetString("mymusic.defaultlibview", GetQuickpathName(item->GetPath())); - g_settings.Save(); + CSettings::Get().SetString("mymusic.defaultlibview", GetQuickpathName(item->GetPath())); + CSettings::Get().Save(); return true; case CONTEXT_BUTTON_CLEAR_DEFAULT: - g_guiSettings.SetString("mymusic.defaultlibview", ""); - g_settings.Save(); + CSettings::Get().SetString("mymusic.defaultlibview", ""); + CSettings::Get().Save(); return true; case CONTEXT_BUTTON_GO_TO_ARTIST: diff --git a/xbmc/music/windows/GUIWindowMusicPlaylist.cpp b/xbmc/music/windows/GUIWindowMusicPlaylist.cpp index 536f7b0275103..edca7c26a71eb 100644 --- a/xbmc/music/windows/GUIWindowMusicPlaylist.cpp +++ b/xbmc/music/windows/GUIWindowMusicPlaylist.cpp @@ -33,9 +33,8 @@ #include "GUIUserMessages.h" #include "Favourites.h" #include "profiles/ProfilesManager.h" -#include "settings/Settings.h" -#include "settings/GUISettings.h" #include "settings/MediaSettings.h" +#include "settings/Settings.h" #include "guilib/LocalizeStrings.h" #include "utils/StringUtils.h" #include "utils/log.h" @@ -140,7 +139,7 @@ bool CGUIWindowMusicPlayList::OnMessage(CGUIMessage& message) { g_playlistPlayer.SetShuffle(PLAYLIST_MUSIC, !(g_playlistPlayer.IsShuffled(PLAYLIST_MUSIC))); CMediaSettings::Get().SetMusicPlaylistShuffled(g_playlistPlayer.IsShuffled(PLAYLIST_MUSIC)); - g_settings.Save(); + CSettings::Get().Save(); UpdateButtons(); Refresh(); } @@ -190,7 +189,7 @@ bool CGUIWindowMusicPlayList::OnMessage(CGUIMessage& message) // save settings CMediaSettings::Get().SetMusicPlaylistRepeat(g_playlistPlayer.GetRepeat(PLAYLIST_MUSIC) == PLAYLIST::REPEAT_ALL); - g_settings.Save(); + CSettings::Get().Save(); UpdateButtons(); } @@ -286,7 +285,7 @@ void CGUIWindowMusicPlayList::SavePlayList() { // need 2 rename it CStdString strFolder, strPath; - URIUtils::AddFileToFolder(g_guiSettings.GetString("system.playlistspath"), "music", strFolder); + URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"), "music", strFolder); strNewFileName= CUtil::MakeLegalFileName( strNewFileName ); strNewFileName += ".m3u"; URIUtils::AddFileToFolder(strFolder, strNewFileName, strPath); @@ -449,12 +448,12 @@ void CGUIWindowMusicPlayList::OnItemLoaded(CFileItem* pItem) if (pItem->HasMusicInfoTag() && pItem->GetMusicInfoTag()->Loaded()) { // set label 1+2 from tags if (m_guiState.get()) m_hideExtensions = m_guiState->HideExtensions(); - CStdString strTrackLeft=g_guiSettings.GetString("musicfiles.nowplayingtrackformat"); + CStdString strTrackLeft=CSettings::Get().GetString("musicfiles.nowplayingtrackformat"); if (strTrackLeft.IsEmpty()) - strTrackLeft = g_guiSettings.GetString("musicfiles.trackformat"); - CStdString strTrackRight=g_guiSettings.GetString("musicfiles.nowplayingtrackformatright"); + strTrackLeft = CSettings::Get().GetString("musicfiles.trackformat"); + CStdString strTrackRight=CSettings::Get().GetString("musicfiles.nowplayingtrackformatright"); if (strTrackRight.IsEmpty()) - strTrackRight = g_guiSettings.GetString("musicfiles.trackformatright"); + strTrackRight = CSettings::Get().GetString("musicfiles.trackformatright"); CLabelFormatter formatter(strTrackLeft, strTrackRight); formatter.FormatLabels(pItem); } // if (pItem->m_musicInfoTag.Loaded()) diff --git a/xbmc/music/windows/GUIWindowMusicPlaylistEditor.cpp b/xbmc/music/windows/GUIWindowMusicPlaylistEditor.cpp index 78f612281cd8d..4108f05532824 100644 --- a/xbmc/music/windows/GUIWindowMusicPlaylistEditor.cpp +++ b/xbmc/music/windows/GUIWindowMusicPlaylistEditor.cpp @@ -32,7 +32,7 @@ #include "guilib/GUIWindowManager.h" #include "guilib/GUIKeyboardFactory.h" #include "FileItem.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "GUIUserMessages.h" #include "guilib/Key.h" #include "guilib/LocalizeStrings.h" @@ -397,7 +397,7 @@ void CGUIWindowMusicPlaylistEditor::OnSavePlaylist() PLAYLIST::CPlayListM3U playlist; playlist.Add(*m_playlist); CStdString path, strBase; - URIUtils::AddFileToFolder(g_guiSettings.GetString("system.playlistspath"), "music", strBase); + URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"), "music", strBase); URIUtils::AddFileToFolder(strBase, name + ".m3u", path); playlist.Save(path); m_strLoadedPlaylist = name; @@ -407,7 +407,7 @@ void CGUIWindowMusicPlaylistEditor::OnSavePlaylist() void CGUIWindowMusicPlaylistEditor::AppendToPlaylist(CFileItemList &newItems) { OnRetrieveMusicInfo(newItems); - FormatItemLabels(newItems, LABEL_MASKS(g_guiSettings.GetString("musicfiles.trackformat"), g_guiSettings.GetString("musicfiles.trackformatright"), "%L", "")); + FormatItemLabels(newItems, LABEL_MASKS(CSettings::Get().GetString("musicfiles.trackformat"), CSettings::Get().GetString("musicfiles.trackformatright"), "%L", "")); m_playlist->Append(newItems); UpdatePlaylist(); } diff --git a/xbmc/music/windows/GUIWindowMusicSongs.cpp b/xbmc/music/windows/GUIWindowMusicSongs.cpp index 376bdd4d4981f..ee77acecb18b7 100644 --- a/xbmc/music/windows/GUIWindowMusicSongs.cpp +++ b/xbmc/music/windows/GUIWindowMusicSongs.cpp @@ -31,8 +31,8 @@ #include "FileItem.h" #include "profiles/ProfilesManager.h" #include "storage/MediaManager.h" -#include "settings/GUISettings.h" #include "settings/MediaSourceSettings.h" +#include "settings/Settings.h" #include "guilib/Key.h" #include "guilib/LocalizeStrings.h" #include "utils/log.h" @@ -354,7 +354,7 @@ void CGUIWindowMusicSongs::GetContextButtons(int itemNumber, CContextButtons &bu if (!item->IsParentFolder() && !item->IsReadOnly()) { // either we're at the playlist location or its been explicitly allowed - if (inPlaylists || g_guiSettings.GetBool("filelists.allowfiledeletion")) + if (inPlaylists || CSettings::Get().GetBool("filelists.allowfiledeletion")) { buttons.Add(CONTEXT_BUTTON_DELETE, 117); buttons.Add(CONTEXT_BUTTON_RENAME, 118); diff --git a/xbmc/music/windows/GUIWindowVisualisation.cpp b/xbmc/music/windows/GUIWindowVisualisation.cpp index 7233d14dab2cc..2920f37a543bd 100644 --- a/xbmc/music/windows/GUIWindowVisualisation.cpp +++ b/xbmc/music/windows/GUIWindowVisualisation.cpp @@ -26,9 +26,8 @@ #include "music/dialogs/GUIDialogVisualisationPresetList.h" #include "guilib/GUIWindowManager.h" #include "guilib/Key.h" -#include "settings/Settings.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" using namespace MUSIC_INFO; @@ -60,7 +59,7 @@ bool CGUIWindowVisualisation::OnAction(const CAction &action) case ACTION_SHOW_INFO: { m_initTimer.Stop(); - g_guiSettings.SetBool("mymusic.songthumbinvis", g_infoManager.ToggleShowInfo()); + CSettings::Get().SetBool("mymusic.songthumbinvis", g_infoManager.ToggleShowInfo()); return true; } break; @@ -71,7 +70,7 @@ bool CGUIWindowVisualisation::OnAction(const CAction &action) case ACTION_SHOW_GUI: // save the settings - g_settings.Save(); + CSettings::Get().Save(); g_windowManager.PreviousWindow(); return true; break; @@ -152,7 +151,7 @@ bool CGUIWindowVisualisation::OnMessage(CGUIMessage& message) case GUI_MSG_WINDOW_DEINIT: { if (IsActive()) // save any changed settings from the OSD - g_settings.Save(); + CSettings::Get().Save(); // check and close any OSD windows CGUIDialogMusicOSD *pOSD = (CGUIDialogMusicOSD *)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_OSD); if (pOSD && pOSD->IsDialogRunning()) pOSD->Close(true); @@ -177,7 +176,7 @@ bool CGUIWindowVisualisation::OnMessage(CGUIMessage& message) if (g_infoManager.GetCurrentSongTag()) m_tag = *g_infoManager.GetCurrentSongTag(); - if (g_guiSettings.GetBool("mymusic.songthumbinvis")) + if (CSettings::Get().GetBool("mymusic.songthumbinvis")) { // always on m_initTimer.Stop(); } @@ -228,7 +227,7 @@ void CGUIWindowVisualisation::FrameMove() if (m_initTimer.IsRunning() && m_initTimer.GetElapsedSeconds() > (float)g_advancedSettings.m_songInfoDuration) { m_initTimer.Stop(); - if (!g_guiSettings.GetBool("mymusic.songthumbinvis")) + if (!CSettings::Get().GetBool("mymusic.songthumbinvis")) { // reached end of fade in, fade out again g_infoManager.SetShowInfo(false); } diff --git a/xbmc/network/AirPlayServer.cpp b/xbmc/network/AirPlayServer.cpp index c3e2de7b24f29..f432c97c37641 100644 --- a/xbmc/network/AirPlayServer.cpp +++ b/xbmc/network/AirPlayServer.cpp @@ -212,6 +212,14 @@ void CAirPlayServer::StopServer(bool bWait) } } +bool CAirPlayServer::IsRunning() +{ + if (ServerInstance == NULL) + return false; + + return ((CThread*)ServerInstance)->IsRunning(); +} + void CAirPlayServer::AnnounceToClients(int state) { CSingleLock lock (m_connectionLock); diff --git a/xbmc/network/AirPlayServer.h b/xbmc/network/AirPlayServer.h index a830aff78a57c..0a30eae63fd4f 100644 --- a/xbmc/network/AirPlayServer.h +++ b/xbmc/network/AirPlayServer.h @@ -46,6 +46,7 @@ class CAirPlayServer : public CThread, public ANNOUNCEMENT::IAnnouncer //AirPlayServer impl. static bool StartServer(int port, bool nonlocal); static void StopServer(bool bWait); + static bool IsRunning(); static bool SetCredentials(bool usePassword, const CStdString& password); static bool IsPlaying(){ return m_isPlaying > 0;} static void backupVolume(); diff --git a/xbmc/network/AirTunesServer.cpp b/xbmc/network/AirTunesServer.cpp index 495c97a228ddd..7194726a13fe1 100644 --- a/xbmc/network/AirTunesServer.cpp +++ b/xbmc/network/AirTunesServer.cpp @@ -580,6 +580,14 @@ void CAirTunesServer::StopServer(bool bWait) } } + bool CAirTunesServer::IsRunning() + { + if (ServerInstance == NULL) + return false; + + return ((CThread*)ServerInstance)->IsRunning(); + } + CAirTunesServer::CAirTunesServer(int port, bool nonlocal) : CThread("AirTunesServer") { m_port = port; diff --git a/xbmc/network/AirTunesServer.h b/xbmc/network/AirTunesServer.h index b776c465066ce..09f6b08563e12 100644 --- a/xbmc/network/AirTunesServer.h +++ b/xbmc/network/AirTunesServer.h @@ -53,6 +53,7 @@ class CAirTunesServer : public CThread, public ANNOUNCEMENT::IAnnouncer static bool StartServer(int port, bool nonlocal, bool usePassword, const CStdString &password=""); static void StopServer(bool bWait); + static bool IsRunning(); static void SetMetadataFromBuffer(const char *buffer, unsigned int size); static void SetCoverArtFromBuffer(const char *buffer, unsigned int size); diff --git a/xbmc/network/EventClient.h b/xbmc/network/EventClient.h index cc1fe527fa23f..d58a5c7e4de08 100644 --- a/xbmc/network/EventClient.h +++ b/xbmc/network/EventClient.h @@ -25,7 +25,7 @@ #include "threads/CriticalSection.h" #include "Socket.h" #include "EventPacket.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include #include @@ -158,8 +158,8 @@ namespace EVENTCLIENT void RefreshSettings() { - m_iRepeatDelay = g_guiSettings.GetInt("services.esinitialdelay"); - m_iRepeatSpeed = g_guiSettings.GetInt("services.escontinuousdelay"); + m_iRepeatDelay = CSettings::Get().GetInt("services.esinitialdelay"); + m_iRepeatSpeed = CSettings::Get().GetInt("services.escontinuousdelay"); } SOCKETS::CAddress& Address() diff --git a/xbmc/network/EventServer.cpp b/xbmc/network/EventServer.cpp index d9691b68c4d53..c07ccffeb7085 100644 --- a/xbmc/network/EventServer.cpp +++ b/xbmc/network/EventServer.cpp @@ -85,13 +85,11 @@ void CEventServer::StartServer() return; // set default port - string port = (const char*)g_guiSettings.GetString("services.esport"); - assert(port.length()); - m_iPort = atoi(port.c_str()); + m_iPort = CSettings::Get().GetInt("services.esport"); assert(m_iPort <= 65535 && m_iPort >= 1); // max clients - m_iMaxClients = g_guiSettings.GetInt("services.esmaxclients"); + m_iMaxClients = CSettings::Get().GetInt("services.esmaxclients"); if (m_iMaxClients < 0) { CLog::Log(LOGERROR, "ES: Invalid maximum number of clients specified %d", m_iMaxClients); @@ -156,7 +154,6 @@ void CEventServer::Run() CAddress any_addr; CSocketListener listener; int packetSize = 0; - std::vector > txt; CLog::Log(LOGNOTICE, "ES: Starting UDP Event server on %s:%d", any_addr.Address(), m_iPort); @@ -178,7 +175,7 @@ void CEventServer::Run() } // bind to IP and start listening on port - int port_range = g_guiSettings.GetInt("services.esportrange"); + int port_range = CSettings::Get().GetInt("services.esportrange"); if (port_range < 1 || port_range > 100) { CLog::Log(LOGERROR, "ES: Invalid port range specified %d, defaulting to 10", port_range); @@ -191,6 +188,7 @@ void CEventServer::Run() } // publish service + std::vector > txt; CZeroconf::GetInstance()->PublishService("servers.eventserver", "_xbmc-events._udp", g_infoManager.GetLabel(SYSTEM_FRIENDLY_NAME), diff --git a/xbmc/network/Makefile.in b/xbmc/network/Makefile.in index e2ffb0bce9454..bf9bed9330344 100644 --- a/xbmc/network/Makefile.in +++ b/xbmc/network/Makefile.in @@ -1,17 +1,18 @@ -SRCS = cddb.cpp -SRCS += DNSNameCache.cpp -SRCS += EventClient.cpp -SRCS += EventPacket.cpp -SRCS += EventServer.cpp -SRCS += GUIDialogAccessPoints.cpp -SRCS += GUIDialogNetworkSetup.cpp -SRCS += Network.cpp -SRCS += Socket.cpp -SRCS += TCPServer.cpp -SRCS += UdpClient.cpp -SRCS += WebServer.cpp -SRCS += ZeroconfBrowser.cpp -SRCS += Zeroconf.cpp +SRCS = cddb.cpp \ + DNSNameCache.cpp \ + EventClient.cpp \ + EventPacket.cpp \ + EventServer.cpp \ + GUIDialogAccessPoints.cpp \ + GUIDialogNetworkSetup.cpp \ + Network.cpp \ + NetworkServices.cpp \ + Socket.cpp \ + TCPServer.cpp \ + UdpClient.cpp \ + WebServer.cpp \ + ZeroconfBrowser.cpp \ + Zeroconf.cpp \ ifeq (@USE_AIRPLAY@, 1) SRCS += AirPlayServer.cpp diff --git a/xbmc/network/Network.cpp b/xbmc/network/Network.cpp index 02dabe3ed5657..8beca4803b2be 100644 --- a/xbmc/network/Network.cpp +++ b/xbmc/network/Network.cpp @@ -18,19 +18,15 @@ * */ -#include "system.h" -#include "Network.h" -#include "Application.h" -#include "ApplicationMessenger.h" -#include "utils/RssManager.h" -#include "utils/log.h" -#include "guilib/LocalizeStrings.h" -#include "dialogs/GUIDialogKaiToast.h" - #include #include #include +#include "Network.h" +#include "ApplicationMessenger.h" +#include "network/NetworkServices.h" +#include "utils/log.h" + using namespace std; /* slightly modified in_ether taken from the etherboot project (http://sourceforge.net/projects/etherboot) */ @@ -128,7 +124,6 @@ CStdString CNetwork::GetHostName(void) return CStdString(hostName); } - CNetworkInterface* CNetwork::GetFirstConnectedInterface() { vector& ifaces = GetInterfaceList(); @@ -204,19 +199,16 @@ void CNetwork::NetworkMessage(EMESSAGE message, int param) switch( message ) { case SERVICES_UP: - { CLog::Log(LOGDEBUG, "%s - Starting network services",__FUNCTION__); - StartServices(); - } - break; + CNetworkServices::Get().Start(); + break; + case SERVICES_DOWN: - { CLog::Log(LOGDEBUG, "%s - Signaling network services to stop",__FUNCTION__); - StopServices(false); //tell network services to stop, but don't wait for them yet + CNetworkServices::Get().Stop(false); // tell network services to stop, but don't wait for them yet CLog::Log(LOGDEBUG, "%s - Waiting for network services to stop",__FUNCTION__); - StopServices(true); //wait for network services to stop - } - break; + CNetworkServices::Get().Stop(true); // wait for network services to stop + break; } } @@ -276,58 +268,3 @@ bool CNetwork::WakeOnLan(const char* mac) CLog::Log(LOGINFO, "%s - Magic packet send to '%s'", __FUNCTION__, mac); return true; } - -void CNetwork::StartServices() -{ -#ifdef HAS_WEB_SERVER - if (!g_application.StartWebServer()) - CGUIDialogKaiToast::QueueNotification("DefaultIconWarning.png", g_localizeStrings.Get(33101), g_localizeStrings.Get(33100)); -#endif -#ifdef HAS_UPNP - g_application.StartUPnP(); -#endif -#ifdef HAS_EVENT_SERVER - if (!g_application.StartEventServer()) - CGUIDialogKaiToast::QueueNotification("DefaultIconWarning.png", g_localizeStrings.Get(33102), g_localizeStrings.Get(33100)); -#endif -#ifdef HAS_JSONRPC - if (!g_application.StartJSONRPCServer()) - CGUIDialogKaiToast::QueueNotification("DefaultIconWarning.png", g_localizeStrings.Get(33103), g_localizeStrings.Get(33100)); -#endif -#ifdef HAS_ZEROCONF - g_application.StartZeroconf(); -#endif -#ifdef HAS_AIRPLAY - g_application.StartAirplayServer(); -#endif - CRssManager::Get().Start(); -} - -void CNetwork::StopServices(bool bWait) -{ - if (bWait) - { -#ifdef HAS_UPNP - g_application.StopUPnP(bWait); -#endif -#ifdef HAS_ZEROCONF - g_application.StopZeroconf(); -#endif -#ifdef HAS_WEB_SERVER - g_application.StopWebServer(); -#endif - // smb.Deinit(); if any file is open over samba this will break. - - CRssManager::Get().Stop(); - } - -#ifdef HAS_EVENT_SERVER - g_application.StopEventServer(bWait, false); -#endif -#ifdef HAS_JSONRPC - g_application.StopJSONRPCServer(bWait); -#endif -#if defined(HAS_AIRPLAY) || defined(HAS_AIRTUNES) - g_application.StopAirplayServer(bWait); -#endif -} diff --git a/xbmc/network/Network.h b/xbmc/network/Network.h index 3f2bdf3bf9aee..3500b70aafecf 100644 --- a/xbmc/network/Network.h +++ b/xbmc/network/Network.h @@ -1,6 +1,4 @@ -#ifndef NETWORK_H_ -#define NETWORK_H_ - +#pragma once /* * Copyright (C) 2005-2013 Team XBMC * http://www.xbmc.org @@ -22,9 +20,12 @@ */ #include -#include "utils/StdString.h" + #include "system.h" +#include "settings/ISettingCallback.h" +#include "utils/StdString.h" + enum EncMode { ENC_NONE = 0, ENC_WEP = 1, ENC_WPA = 2, ENC_WPA2 = 3 }; enum NetworkAssignment { NETWORK_DASH = 0, NETWORK_DHCP = 1, NETWORK_STATIC = 2, NETWORK_DISABLED = 3 }; @@ -74,8 +75,6 @@ class CNetworkInterface virtual void SetSettings(NetworkAssignment& assignment, CStdString& ipAddress, CStdString& networkMask, CStdString& defaultGateway, CStdString& essId, CStdString& key, EncMode& encryptionMode) = 0; }; - - class CNetwork { public: @@ -122,9 +121,9 @@ class CNetwork static int ParseHex(char *str, unsigned char *addr); }; + #ifdef HAS_LINUX_NETWORK #include "linux/NetworkLinux.h" #else #include "windows/NetworkWin32.h" #endif -#endif diff --git a/xbmc/network/NetworkServices.cpp b/xbmc/network/NetworkServices.cpp new file mode 100644 index 0000000000000..97d712b613175 --- /dev/null +++ b/xbmc/network/NetworkServices.cpp @@ -0,0 +1,931 @@ +/* + * Copyright (C) 2005-2012 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 + * . + * + */ + +#include "NetworkServices.h" +#include "Application.h" +#include "ApplicationMessenger.h" +#include "GUIInfoManager.h" +#ifdef TARGET_LINUX +#include "Util.h" +#endif +#include "dialogs/GUIDialogKaiToast.h" +#include "dialogs/GUIDialogOK.h" +#include "dialogs/GUIDialogYesNo.h" +#include "guilib/LocalizeStrings.h" +#include "network/Network.h" + +#ifdef HAS_AIRPLAY +#include "network/AirPlayServer.h" +#endif // HAS_AIRPLAY + +#ifdef HAS_AIRTUNES +#include "network/AirTunesServer.h" +#endif // HAS_AIRTUNES + +#ifdef HAS_EVENT_SERVER +#include "network/EventServer.h" +#endif // HAS_EVENT_SERVER + +#ifdef HAS_JSONRPC +#include "interfaces/json-rpc/JSONRPC.h" +#include "network/TCPServer.h" +#endif + +#ifdef HAS_ZEROCONF +#include "network/Zeroconf.h" +#endif // HAS_ZEROCONF + +#ifdef HAS_UPNP +#include "network/upnp/UPnP.h" +#endif // HAS_UPNP + +#ifdef HAS_WEB_SERVER +#include "network/WebServer.h" +#include "network/httprequesthandler/HTTPImageHandler.h" +#include "network/httprequesthandler/HTTPVfsHandler.h" +#ifdef HAS_JSONRPC +#include "network/httprequesthandler/HTTPJsonRpcHandler.h" +#endif // HAS_JSONRPC +#ifdef HAS_WEB_INTERFACE +#include "network/httprequesthandler/HTTPWebinterfaceHandler.h" +#include "network/httprequesthandler/HTTPWebinterfaceAddonsHandler.h" +#endif // HAS_WEB_INTERFACE +#endif // HAS_WEB_SERVER + +#if defined(TARGET_DARWIN_OSX) +#include "osx/XBMCHelper.h" +#endif + +#include "settings/AdvancedSettings.h" +#include "settings/Settings.h" +#include "utils/log.h" +#include "utils/RssManager.h" + +using namespace std; +#ifdef HAS_JSONRPC +using namespace JSONRPC; +#endif // HAS_JSONRPC +#ifdef HAS_EVENT_SERVER +using namespace EVENTSERVER; +#endif // HAS_EVENT_SERVER +#ifdef HAS_UPNP +using namespace UPNP; +#endif // HAS_UPNP + +CNetworkServices::CNetworkServices() + : +#ifdef HAS_WEB_SERVER + m_webserver(*new CWebServer), + m_httpImageHandler(*new CHTTPImageHandler), + m_httpVfsHandler(*new CHTTPVfsHandler) +#ifdef HAS_JSONRPC + , m_httpJsonRpcHandler(*new CHTTPJsonRpcHandler) +#endif // HAS_JSONRPC +#ifdef HAS_WEB_INTERFACE + , m_httpWebinterfaceHandler(*new CHTTPWebinterfaceHandler) + , m_httpWebinterfaceAddonsHandler(*new CHTTPWebinterfaceAddonsHandler) +#endif // HAS_WEB_INTERFACE +#endif // HAS_WEB_SERVER +{ +#ifdef HAS_WEB_SERVER + CWebServer::RegisterRequestHandler(&m_httpImageHandler); + CWebServer::RegisterRequestHandler(&m_httpVfsHandler); +#ifdef HAS_JSONRPC + CWebServer::RegisterRequestHandler(&m_httpJsonRpcHandler); +#endif // HAS_JSONRPC +#ifdef HAS_WEB_INTERFACE + CWebServer::RegisterRequestHandler(&m_httpWebinterfaceAddonsHandler); + CWebServer::RegisterRequestHandler(&m_httpWebinterfaceHandler); +#endif // HAS_WEB_INTERFACE +#endif // HAS_WEB_SERVER +} + +CNetworkServices::~CNetworkServices() +{ +#ifdef HAS_WEB_SERVER + CWebServer::UnregisterRequestHandler(&m_httpImageHandler); + delete &m_httpImageHandler; + CWebServer::UnregisterRequestHandler(&m_httpVfsHandler); + delete &m_httpVfsHandler; +#ifdef HAS_JSONRPC + CWebServer::UnregisterRequestHandler(&m_httpJsonRpcHandler); + delete &m_httpJsonRpcHandler; + CJSONRPC::Cleanup(); +#endif // HAS_JSONRPC +#ifdef HAS_WEB_INTERFACE + CWebServer::UnregisterRequestHandler(&m_httpWebinterfaceAddonsHandler); + delete &m_httpWebinterfaceAddonsHandler; + CWebServer::UnregisterRequestHandler(&m_httpWebinterfaceHandler); + delete &m_httpWebinterfaceHandler; +#endif // HAS_WEB_INTERFACE + delete &m_webserver; +#endif // HAS_WEB_SERVER +} + +CNetworkServices& CNetworkServices::Get() +{ + static CNetworkServices sNetworkServices; + return sNetworkServices; +} + +bool CNetworkServices::OnSettingChanging(const CSetting *setting) +{ + if (setting == NULL) + return false; + + const std::string &settingId = setting->GetId(); +#ifdef HAS_WEB_SERVER + if (settingId == "services.webserver" || + settingId == "services.webserverport") + { + if (IsWebserverRunning() && !StopWebserver()) + return false; + + if (CSettings::Get().GetBool("services.webserver")) + { + if (!StartWebserver()) + { + CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33101), "", g_localizeStrings.Get(33100), ""); + return false; + } + } + } + else if (settingId == "services.esport" || + settingId == "services.webserverport") + return ValidatePort(((CSettingInt*)setting)->GetValue()); + else +#endif // HAS_WEB_SERVER + +#ifdef HAS_ZEROCONF + if (settingId == "services.zeroconf") + { + if (((CSettingBool*)setting)->GetValue()) + return StartZeroconf(); +#ifdef HAS_AIRPLAY + else + { + // cannot disable + if (IsAirPlayServerRunning() || IsAirTunesServerRunning()) + { + CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(1259), g_localizeStrings.Get(34303), g_localizeStrings.Get(34304), ""); + return false; + } + + return StopZeroconf(); + } +#endif // HAS_AIRPLAY + } + else +#endif // HAS_ZEROCONF + +#ifdef HAS_AIRPLAY + if (settingId == "services.airplay") + { + if (((CSettingBool*)setting)->GetValue()) + { +#ifdef HAS_ZEROCONF + // AirPlay needs zeroconf + if (!CSettings::Get().GetBool("services.zeroconf")) + { + CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(1273), g_localizeStrings.Get(33100), g_localizeStrings.Get(34302), ""); + return false; + } +#endif //HAS_ZEROCONF + + if (!StartAirPlayServer()) + { + CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(1273), "", g_localizeStrings.Get(33100), ""); + return false; + } + + if (!CAirPlayServer::SetCredentials(CSettings::Get().GetBool("services.useairplaypassword"), + CSettings::Get().GetString("services.airplaypassword"))) + { + CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(1273), "", g_localizeStrings.Get(33100), ""); + return false; + } + + if (!StartAirTunesServer()) + { + CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(1274), "", g_localizeStrings.Get(33100), ""); + return false; + } + } + else + { + if (!StopAirPlayServer(true) || !StopAirTunesServer(true)) + return false; + } + } + else if (settingId == "services.airplaypassword" || + settingId == "services.useairplaypassword") + { + if (!CSettings::Get().GetBool("services.airplay")) + return false; + + if (!CAirPlayServer::SetCredentials(CSettings::Get().GetBool("services.useairplaypassword"), + CSettings::Get().GetString("services.airplaypassword"))) + return false; + } + else +#endif //HAS_AIRPLAY + +#ifdef HAS_UPNP + if (settingId == "services.upnpserver") + { + if (((CSettingBool*)setting)->GetValue()) + return StartUPnPServer(); + else + return StopUPnPServer(); + } + else if (settingId == "services.upnprenderer") + { + if (((CSettingBool*)setting)->GetValue()) + return StartUPnPRenderer(); + else + return StopUPnPRenderer(); + } + else if (settingId == "services.upnpcontroller") + { + // always stop and restart + StopUPnPClient(); + if (((CSettingBool*)setting)->GetValue()) + return StartUPnPClient(); + } + else +#endif // HAS_UPNP + + if (settingId == "services.esenabled") + { +#ifdef HAS_EVENT_SERVER + if (((CSettingBool*)setting)->GetValue()) + { + if (!StartEventServer()) + { + CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33102), "", g_localizeStrings.Get(33100), ""); + return false; + } + } + else + return StopEventServer(true, true); +#endif // HAS_EVENT_SERVER + +#ifdef HAS_JSONRPC + if (CSettings::Get().GetBool("services.esenabled")) + { + if (!StartJSONRPCServer()) + { + CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33103), "", g_localizeStrings.Get(33100), ""); + return false; + } + } + else + return StopJSONRPCServer(false); +#endif // HAS_JSONRPC + } + else if (settingId == "services.esport") + { +#ifdef HAS_EVENT_SERVER + // restart eventserver without asking user + if (!StopEventServer(true, false)) + return false; + + if (!StartEventServer()) + { + CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33102), "", g_localizeStrings.Get(33100), ""); + return false; + } + +#if defined(TARGET_DARWIN_OSX) + // reconfigure XBMCHelper for port changes + XBMCHelper::GetInstance().Configure(); +#endif // TARGET_DARWIN_OSX +#endif // HAS_EVENT_SERVER + } + else if (settingId == "services.esallinterfaces") + { +#ifdef HAS_EVENT_SERVER + if (CSettings::Get().GetBool("services.esenabled")) + { + if (!StopEventServer(true, true)) + return false; + + if (!StartEventServer()) + { + CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33102), "", g_localizeStrings.Get(33100), ""); + return false; + } + } +#endif // HAS_EVENT_SERVER + +#ifdef HAS_JSONRPC + if (CSettings::Get().GetBool("services.esenabled")) + { + if (!StartJSONRPCServer()) + { + CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33103), "", g_localizeStrings.Get(33100), ""); + return false; + } + } +#endif // HAS_JSONRPC + } + +#ifdef HAS_EVENT_SERVER + else if (settingId == "services.esinitialdelay" || + settingId == "services.escontinuousdelay") + { + if (CSettings::Get().GetBool("services.esenabled")) + return RefreshEventServer(); + } +#endif // HAS_EVENT_SERVER + + return true; +} + +void CNetworkServices::OnSettingChanged(const CSetting *setting) +{ + if (setting == NULL) + return; + + const std::string &settingId = setting->GetId(); +#ifdef HAS_WEB_SERVER + if (settingId == "services.webserverusername" || + settingId == "services.webserverpassword") + { + m_webserver.SetCredentials(CSettings::Get().GetString("services.webserverusername"), + CSettings::Get().GetString("services.webserverpassword")); + } + else +#endif // HAS_WEB_SERVER + if (settingId == "smb.winsserver" || + settingId == "smb.workgroup") + { + // okey we really don't need to restart, only deinit samba, but that could be damn hard if something is playing + // TODO - General way of handling setting changes that require restart + if (CGUIDialogYesNo::ShowAndGetInput(14038, 14039, 14040, -1, -1)) + { + CSettings::Get().Save(); + CApplicationMessenger::Get().RestartApp(); + } + } +} + +void CNetworkServices::Start() +{ + StartZeroconf(); + if (!StartWebserver()) + CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Warning, g_localizeStrings.Get(33101), g_localizeStrings.Get(33100)); + StartUPnP(); + if (!StartEventServer()) + CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Warning, g_localizeStrings.Get(33102), g_localizeStrings.Get(33100)); + if (!StartJSONRPCServer()) + CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Warning, g_localizeStrings.Get(33103), g_localizeStrings.Get(33100)); + StartAirPlayServer(); + StartAirTunesServer(); + StartRss(); +} + +void CNetworkServices::Stop(bool bWait) +{ + if (bWait) + { + StopUPnP(bWait); + StopZeroconf(); + StopWebserver(); + StopRss(); + } + + StopEventServer(bWait, false); + StopJSONRPCServer(bWait); + StopAirPlayServer(bWait); + StopAirTunesServer(bWait); +} + +bool CNetworkServices::StartWebserver() +{ +#ifdef HAS_WEB_SERVER + if (!g_application.getNetwork().IsAvailable()) + return false; + + if (!CSettings::Get().GetBool("services.webserver")) + return false; + + int webPort = CSettings::Get().GetInt("services.webserverport"); + if (!ValidatePort(webPort)) + { + CLog::Log(LOGERROR, "Cannot start Web Server on port %i", webPort); + return false; + } + + if (IsWebserverRunning()) + return true; + + CLog::Log(LOGNOTICE, "Webserver: Starting..."); + if (!m_webserver.Start(webPort, CSettings::Get().GetString("services.webserverusername"), CSettings::Get().GetString("services.webserverpassword"))) + return false; + +#ifdef HAS_ZEROCONF + std::vector > txt; + // publish web frontend and API services +#ifdef HAS_WEB_INTERFACE + CZeroconf::GetInstance()->PublishService("servers.webserver", "_http._tcp", g_infoManager.GetLabel(SYSTEM_FRIENDLY_NAME), webPort, txt); +#endif // HAS_WEB_INTERFACE +#ifdef HAS_JSONRPC + CZeroconf::GetInstance()->PublishService("servers.jsonrpc-http", "_xbmc-jsonrpc-h._tcp", g_infoManager.GetLabel(SYSTEM_FRIENDLY_NAME), webPort, txt); +#endif // HAS_JSONRPC +#endif // HAS_ZEROCONF + + return true; +#endif // HAS_WEB_SERVER + return false; +} + +bool CNetworkServices::IsWebserverRunning() +{ +#ifdef HAS_WEB_SERVER + return m_webserver.IsStarted(); +#endif // HAS_WEB_SERVER + return false; +} + +bool CNetworkServices::StopWebserver() +{ +#ifdef HAS_WEB_SERVER + if (!IsWebserverRunning()) + return true; + + CLog::Log(LOGNOTICE, "Webserver: Stopping..."); + if (!m_webserver.Stop() || m_webserver.IsStarted()) + { + CLog::Log(LOGWARNING, "Webserver: Failed to stop."); + return false; + } + + CLog::Log(LOGNOTICE, "Webserver: Stopped..."); +#ifdef HAS_ZEROCONF +#ifdef HAS_WEB_INTERFACE + CZeroconf::GetInstance()->RemoveService("servers.webserver"); +#endif // HAS_WEB_INTERFACE +#ifdef HAS_JSONRPC + CZeroconf::GetInstance()->RemoveService("servers.jsonrpc-http"); +#endif // HAS_JSONRPC +#endif // HAS_ZEROCONF + + return true; +#endif // HAS_WEB_SERVER + return false; +} + +bool CNetworkServices::StartAirPlayServer() +{ +#ifdef HAS_AIRPLAY + if (!g_application.getNetwork().IsAvailable() || !CSettings::Get().GetBool("services.airplay")) + return false; + + if (IsAirPlayServerRunning()) + return true; + + if (!CAirPlayServer::StartServer(g_advancedSettings.m_airPlayPort, true)) + return false; + + if (!CAirPlayServer::SetCredentials(CSettings::Get().GetBool("services.useairplaypassword"), + CSettings::Get().GetString("services.airplaypassword"))) + return false; + +#ifdef HAS_ZEROCONF + std::vector > txt; + CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface(); + txt.push_back(make_pair("deviceid", iface != NULL ? iface->GetMacAddress() : "FF:FF:FF:FF:FF:F2")); + txt.push_back(make_pair("features", "0x77")); + txt.push_back(make_pair("model", "Xbmc,1")); + txt.push_back(make_pair("srcvers", AIRPLAY_SERVER_VERSION_STR)); + CZeroconf::GetInstance()->PublishService("servers.airplay", "_airplay._tcp", g_infoManager.GetLabel(SYSTEM_FRIENDLY_NAME), g_advancedSettings.m_airPlayPort, txt); +#endif // HAS_ZEROCONF + + return true; +#endif // HAS_AIRPLAY + return false; +} + +bool CNetworkServices::IsAirPlayServerRunning() +{ +#ifdef HAS_AIRPLAY + return CAirPlayServer::IsRunning(); +#endif // HAS_AIRPLAY + return false; +} + +bool CNetworkServices::StopAirPlayServer(bool bWait) +{ +#ifdef HAS_AIRPLAY + if (!IsAirPlayServerRunning()) + return true; + + CAirPlayServer::StopServer(bWait); + +#ifdef HAS_ZEROCONF + CZeroconf::GetInstance()->RemoveService("servers.airplay"); +#endif // HAS_ZEROCONF + + return true; +#endif // HAS_AIRPLAY + return false; +} + +bool CNetworkServices::StartAirTunesServer() +{ +#ifdef HAS_AIRTUNES + if (!g_application.getNetwork().IsAvailable() || !CSettings::Get().GetBool("services.airplay")) + return false; + + if (IsAirTunesServerRunning()) + return true; + + if (!CAirTunesServer::StartServer(g_advancedSettings.m_airTunesPort, true, + CSettings::Get().GetBool("services.useairplaypassword"), + CSettings::Get().GetString("services.airplaypassword"))) + { + CLog::Log(LOGERROR, "Failed to start AirTunes Server"); + return false; + } + + return true; +#endif // HAS_AIRTUNES + return false; +} + +bool CNetworkServices::IsAirTunesServerRunning() +{ +#ifdef HAS_AIRTUNES + return CAirTunesServer::IsRunning(); +#endif // HAS_AIRTUNES + return false; +} + +bool CNetworkServices::StopAirTunesServer(bool bWait) +{ +#ifdef HAS_AIRTUNES + if (!IsAirTunesServerRunning()) + return true; + + CAirTunesServer::StopServer(bWait); + return true; +#endif // HAS_AIRTUNES + return false; +} + +bool CNetworkServices::StartJSONRPCServer() +{ +#ifdef HAS_JSONRPC + if (!CSettings::Get().GetBool("services.esenabled")) + return false; + + if (IsJSONRPCServerRunning()) + return true; + + if (!CTCPServer::StartServer(g_advancedSettings.m_jsonTcpPort, CSettings::Get().GetBool("services.esallinterfaces"))) + return false; + +#ifdef HAS_ZEROCONF + std::vector > txt; + CZeroconf::GetInstance()->PublishService("servers.jsonrpc-tpc", "_xbmc-jsonrpc._tcp", g_infoManager.GetLabel(SYSTEM_FRIENDLY_NAME), g_advancedSettings.m_jsonTcpPort, txt); +#endif // HAS_ZEROCONF + + return true; +#endif // HAS_JSONRPC + return false; +} + +bool CNetworkServices::IsJSONRPCServerRunning() +{ +#ifdef HAS_JSONRPC + return CTCPServer::IsRunning(); +#endif // HAS_JSONRPC + return false; +} + +bool CNetworkServices::StopJSONRPCServer(bool bWait) +{ +#ifdef HAS_JSONRPC + if (!IsJSONRPCServerRunning()) + return true; + + CTCPServer::StopServer(bWait); + +#ifdef HAS_ZEROCONF + CZeroconf::GetInstance()->RemoveService("servers.jsonrpc-tcp"); +#endif // HAS_ZEROCONF + + return true; +#endif // HAS_JSONRPC + return false; +} + +bool CNetworkServices::StartEventServer() +{ +#ifdef HAS_EVENT_SERVER + if (!CSettings::Get().GetBool("services.esenabled")) + return false; + + if (IsEventServerRunning()) + return true; + + CEventServer* server = CEventServer::GetInstance(); + if (!server) + { + CLog::Log(LOGERROR, "ES: Out of memory"); + return false; + } + + CLog::Log(LOGNOTICE, "ES: Starting event server"); + server->StartServer(); + + return true; +#endif // HAS_EVENT_SERVER + return false; +} + +bool CNetworkServices::IsEventServerRunning() +{ +#ifdef HAS_EVENT_SERVER + return CEventServer::GetInstance()->Running(); +#endif // HAS_EVENT_SERVER + return false; +} + +bool CNetworkServices::StopEventServer(bool bWait, bool promptuser) +{ +#ifdef HAS_EVENT_SERVER + if (!IsEventServerRunning()) + return true; + + CEventServer* server = CEventServer::GetInstance(); + if (!server) + { + CLog::Log(LOGERROR, "ES: Out of memory"); + return false; + } + + if (promptuser) + { + if (server->GetNumberOfClients() > 0) + { + bool cancelled = false; + if (!CGUIDialogYesNo::ShowAndGetInput(13140, 13141, 13142, 20022, + -1, -1, cancelled, 10000) + || cancelled) + { + CLog::Log(LOGNOTICE, "ES: Not stopping event server"); + return false; + } + } + CLog::Log(LOGNOTICE, "ES: Stopping event server with confirmation"); + + CEventServer::GetInstance()->StopServer(true); + } + else + { + if (!bWait) + CLog::Log(LOGNOTICE, "ES: Stopping event server"); + + CEventServer::GetInstance()->StopServer(bWait); + } + + return true; +#endif // HAS_EVENT_SERVER + return false; +} + +bool CNetworkServices::RefreshEventServer() +{ +#ifdef HAS_EVENT_SERVER + if (!CSettings::Get().GetBool("services.esenabled")) + return false; + + if (!IsEventServerRunning()) + return false; + + CEventServer::GetInstance()->RefreshSettings(); + return true; +#endif // HAS_EVENT_SERVER + return false; +} + +bool CNetworkServices::StartUPnP() +{ + bool ret = false; +#ifdef HAS_UPNP + ret |= StartUPnPClient(); + ret |= StartUPnPServer(); + ret |= StartUPnPRenderer(); + return true; +#endif // HAS_UPNP + return ret; +} + +bool CNetworkServices::StopUPnP(bool bWait) +{ +#ifdef HAS_UPNP + if (!CUPnP::IsInstantiated()) + return true; + + CLog::Log(LOGNOTICE, "stopping upnp"); + CUPnP::ReleaseInstance(bWait); + + return true; +#endif // HAS_UPNP + return false; +} + +bool CNetworkServices::StartUPnPClient() +{ +#ifdef HAS_UPNP + if (!CSettings::Get().GetBool("services.upnpcontroller")) + return false; + + CLog::Log(LOGNOTICE, "starting upnp controller"); + CUPnP::GetInstance()->StartClient(); + return IsUPnPClientRunning(); +#endif // HAS_UPNP + return false; +} + +bool CNetworkServices::IsUPnPClientRunning() +{ +#ifdef HAS_UPNP + return CUPnP::GetInstance()->IsClientStarted(); +#endif // HAS_UPNP + return false; +} + +bool CNetworkServices::StopUPnPClient() +{ +#ifdef HAS_UPNP + if (!IsUPnPRendererRunning()) + return true; + + CLog::Log(LOGNOTICE, "stopping upnp client"); + CUPnP::GetInstance()->StopClient(); + + return true; +#endif // HAS_UPNP + return false; +} + +bool CNetworkServices::StartUPnPRenderer() +{ +#ifdef HAS_UPNP + if (!CSettings::Get().GetBool("services.upnprenderer")) + return false; + + CLog::Log(LOGNOTICE, "starting upnp renderer"); + return CUPnP::GetInstance()->StartRenderer(); +#endif // HAS_UPNP + return false; +} + +bool CNetworkServices::IsUPnPRendererRunning() +{ +#ifdef HAS_UPNP + return CUPnP::GetInstance()->IsInstantiated(); +#endif // HAS_UPNP + return false; +} + +bool CNetworkServices::StopUPnPRenderer() +{ +#ifdef HAS_UPNP + if (!IsUPnPRendererRunning()) + return true; + + CLog::Log(LOGNOTICE, "stopping upnp renderer"); + CUPnP::GetInstance()->StopRenderer(); + + return true; +#endif // HAS_UPNP + return false; +} + +bool CNetworkServices::StartUPnPServer() +{ +#ifdef HAS_UPNP + if (!CSettings::Get().GetBool("services.upnpserver")) + return false; + + CLog::Log(LOGNOTICE, "starting upnp server"); + return CUPnP::GetInstance()->StartServer(); +#endif // HAS_UPNP + return false; +} + +bool CNetworkServices::IsUPnPServerRunning() +{ +#ifdef HAS_UPNP + return CUPnP::GetInstance()->IsInstantiated(); +#endif // HAS_UPNP + return false; +} + +bool CNetworkServices::StopUPnPServer() +{ +#ifdef HAS_UPNP + if (!IsUPnPRendererRunning()) + return true; + + CLog::Log(LOGNOTICE, "stopping upnp server"); + CUPnP::GetInstance()->StopServer(); + + return true; +#endif // HAS_UPNP + return false; +} + +bool CNetworkServices::StartRss() +{ + if (IsRssRunning()) + return true; + + CRssManager::Get().Start(); + return true; +} + +bool CNetworkServices::IsRssRunning() +{ + return CRssManager::Get().IsActive(); +} + +bool CNetworkServices::StopRss() +{ + if (!IsRssRunning()) + return true; + + CRssManager::Get().Stop(); + return true; +} + +bool CNetworkServices::StartZeroconf() +{ +#ifdef HAS_ZEROCONF + if (!CSettings::Get().GetBool("services.zeroconf")) + return false; + + if (IsZeroconfRunning()) + return true; + + CLog::Log(LOGNOTICE, "starting zeroconf publishing"); + return CZeroconf::GetInstance()->Start(); +#endif // HAS_ZEROCONF + return false; +} + +bool CNetworkServices::IsZeroconfRunning() +{ +#ifdef HAS_ZEROCONF + return CZeroconf::GetInstance()->IsInstantiated(); +#endif // HAS_ZEROCONF + return false; +} + +bool CNetworkServices::StopZeroconf() +{ +#ifdef HAS_ZEROCONF + if (!IsZeroconfRunning()) + return true; + + CLog::Log(LOGNOTICE, "stopping zeroconf publishing"); + CZeroconf::GetInstance()->Stop(); + + return true; +#endif // HAS_ZEROCONF + return false; +} + +bool CNetworkServices::ValidatePort(int port) +{ + if (port <= 0 || port > 65535) + return false; + +#ifdef TARGET_LINUX + if (!CUtil::CanBindPrivileged() && (port < 1024 || port > 65535)) + return false; +#endif + + return true; +} diff --git a/xbmc/network/NetworkServices.h b/xbmc/network/NetworkServices.h new file mode 100644 index 0000000000000..750df17dd4593 --- /dev/null +++ b/xbmc/network/NetworkServices.h @@ -0,0 +1,109 @@ +#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 + * . + * + */ + +#include "system.h" +#include "settings/ISettingCallback.h" + +#ifdef HAS_WEB_SERVER +class CWebServer; +class CHTTPImageHandler; +class CHTTPVfsHandler; +#ifdef HAS_JSONRPC +class CHTTPJsonRpcHandler; +#endif // HAS_JSONRPC +#ifdef HAS_WEB_INTERFACE +class CHTTPWebinterfaceHandler; +class CHTTPWebinterfaceAddonsHandler; +#endif // HAS_WEB_INTERFACE +#endif // HAS_WEB_SERVER + +class CNetworkServices : public ISettingCallback +{ +public: + static CNetworkServices& Get(); + + virtual bool OnSettingChanging(const CSetting *setting); + virtual void OnSettingChanged(const CSetting *setting); + + void Start(); + void Stop(bool bWait); + + bool StartWebserver(); + bool IsWebserverRunning(); + bool StopWebserver(); + + bool StartAirPlayServer(); + bool IsAirPlayServerRunning(); + bool StopAirPlayServer(bool bWait); + bool StartAirTunesServer(); + bool IsAirTunesServerRunning(); + bool StopAirTunesServer(bool bWait); + + bool StartJSONRPCServer(); + bool IsJSONRPCServerRunning(); + bool StopJSONRPCServer(bool bWait); + + bool StartEventServer(); + bool IsEventServerRunning(); + bool StopEventServer(bool bWait, bool promptuser); + bool RefreshEventServer(); + + bool StartUPnP(); + bool StopUPnP(bool bWait); + bool StartUPnPClient(); + bool IsUPnPClientRunning(); + bool StopUPnPClient(); + bool StartUPnPRenderer(); + bool IsUPnPRendererRunning(); + bool StopUPnPRenderer(); + bool StartUPnPServer(); + bool IsUPnPServerRunning(); + bool StopUPnPServer(); + + bool StartRss(); + bool IsRssRunning(); + bool StopRss(); + + bool StartZeroconf(); + bool IsZeroconfRunning(); + bool StopZeroconf(); + +private: + CNetworkServices(); + CNetworkServices(const CNetworkServices&); + CNetworkServices const& operator=(CNetworkServices const&); + virtual ~CNetworkServices(); + + bool ValidatePort(int port); + +#ifdef HAS_WEB_SERVER + CWebServer& m_webserver; + CHTTPImageHandler& m_httpImageHandler; + CHTTPVfsHandler& m_httpVfsHandler; +#ifdef HAS_JSONRPC + CHTTPJsonRpcHandler& m_httpJsonRpcHandler; +#endif +#ifdef HAS_WEB_INTERFACE + CHTTPWebinterfaceHandler& m_httpWebinterfaceHandler; + CHTTPWebinterfaceAddonsHandler& m_httpWebinterfaceAddonsHandler; +#endif +#endif +}; diff --git a/xbmc/network/TCPServer.cpp b/xbmc/network/TCPServer.cpp index ec7d4c7cc7299..9aa3894e44c2f 100644 --- a/xbmc/network/TCPServer.cpp +++ b/xbmc/network/TCPServer.cpp @@ -85,6 +85,14 @@ void CTCPServer::StopServer(bool bWait) } } +bool CTCPServer::IsRunning() +{ + if (ServerInstance == NULL) + return false; + + return ((CThread*)ServerInstance)->IsRunning(); +} + CTCPServer::CTCPServer(int port, bool nonlocal) : CThread("TCPServer") { m_port = port; diff --git a/xbmc/network/TCPServer.h b/xbmc/network/TCPServer.h index 5de68e75dc234..5fd8ac971f053 100644 --- a/xbmc/network/TCPServer.h +++ b/xbmc/network/TCPServer.h @@ -36,6 +36,7 @@ namespace JSONRPC public: static bool StartServer(int port, bool nonlocal); static void StopServer(bool bWait); + static bool IsRunning(); virtual bool PrepareDownload(const char *path, CVariant &details, std::string &protocol); virtual bool Download(const char *path, CVariant &result); diff --git a/xbmc/network/WebServer.cpp b/xbmc/network/WebServer.cpp index 71ce952290630..e8694965a546c 100644 --- a/xbmc/network/WebServer.cpp +++ b/xbmc/network/WebServer.cpp @@ -20,14 +20,15 @@ #include "WebServer.h" #ifdef HAS_WEB_SERVER +#include "URL.h" +#include "XBDateTime.h" #include "filesystem/File.h" +#include "settings/Settings.h" +#include "threads/SingleLock.h" +#include "utils/Base64.h" #include "utils/log.h" #include "utils/URIUtils.h" #include "utils/Variant.h" -#include "utils/Base64.h" -#include "threads/SingleLock.h" -#include "XBDateTime.h" -#include "URL.h" #ifdef _WIN32 #pragma comment(lib, "libmicrohttpd.dll.lib") diff --git a/xbmc/network/WebServer.h b/xbmc/network/WebServer.h index b48d43d84409b..d86f063b59cd3 100644 --- a/xbmc/network/WebServer.h +++ b/xbmc/network/WebServer.h @@ -29,9 +29,10 @@ #include #include #include + #include "interfaces/json-rpc/ITransportLayer.h" +#include "network/httprequesthandler/IHTTPRequestHandler.h" #include "threads/CriticalSection.h" -#include "httprequesthandler/IHTTPRequestHandler.h" class CWebServer : public JSONRPC::ITransportLayer { @@ -54,6 +55,7 @@ class CWebServer : public JSONRPC::ITransportLayer static std::string GetRequestHeaderValue(struct MHD_Connection *connection, enum MHD_ValueKind kind, const std::string &key); static int GetRequestHeaderValues(struct MHD_Connection *connection, enum MHD_ValueKind kind, std::map &headerValues); static int GetRequestHeaderValues(struct MHD_Connection *connection, enum MHD_ValueKind kind, std::multimap &headerValues); + private: struct MHD_Daemon* StartMHD(unsigned int flags, int port); static int AskForAuthentication (struct MHD_Connection *connection); diff --git a/xbmc/network/Zeroconf.cpp b/xbmc/network/Zeroconf.cpp index b1130f6f80259..f0d1ddb5f072d 100644 --- a/xbmc/network/Zeroconf.cpp +++ b/xbmc/network/Zeroconf.cpp @@ -19,7 +19,7 @@ */ #include "system.h" //HAS_ZEROCONF define #include "Zeroconf.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #ifdef _LINUX #if !defined(TARGET_DARWIN) @@ -67,7 +67,7 @@ bool CZeroconf::PublishService(const std::string& fcr_identifier, const std::string& fcr_type, const std::string& fcr_name, unsigned int f_port, - const std::vector >& txt) + std::vector > txt /* = std::vector >() */) { CSingleLock lock(*mp_crit_sec); CZeroconf::PublishInfo info = {fcr_type, fcr_name, f_port, txt}; @@ -99,21 +99,22 @@ bool CZeroconf::HasService(const std::string& fcr_identifier) const return (m_service_map.find(fcr_identifier) != m_service_map.end()); } -void CZeroconf::Start() +bool CZeroconf::Start() { CSingleLock lock(*mp_crit_sec); if(!IsZCdaemonRunning()) { - g_guiSettings.SetBool("services.zeroconf", false); - if (g_guiSettings.GetBool("services.airplay")) - g_guiSettings.SetBool("services.airplay", false); - return; + CSettings::Get().SetBool("services.zeroconf", false); + if (CSettings::Get().GetBool("services.airplay")) + CSettings::Get().SetBool("services.airplay", false); + return false; } if(m_started) - return; + return true; m_started = true; CJobManager::GetInstance().AddJob(new CPublish(m_service_map), NULL); + return true; } void CZeroconf::Stop() diff --git a/xbmc/network/Zeroconf.h b/xbmc/network/Zeroconf.h index bf700b4a15240..b4d3fa9e48958 100644 --- a/xbmc/network/Zeroconf.h +++ b/xbmc/network/Zeroconf.h @@ -50,7 +50,7 @@ class CZeroconf const std::string& fcr_type, const std::string& fcr_name, unsigned int f_port, - const std::vector >& txt); + std::vector > txt /*= std::vector >()*/); ///removes the specified service ///returns false if fcr_identifier does not exist @@ -62,7 +62,7 @@ class CZeroconf //starts publishing //services that were added with PublishService(...) while Zeroconf wasn't //started, get published now. - void Start(); + bool Start(); // unpublishs all services (but keeps them stored in this class) // a call to Start() will republish them diff --git a/xbmc/network/upnp/UPnP.cpp b/xbmc/network/upnp/UPnP.cpp index f3aa9dae51c00..373a656612b6d 100644 --- a/xbmc/network/upnp/UPnP.cpp +++ b/xbmc/network/upnp/UPnP.cpp @@ -34,7 +34,7 @@ #include "Platinum.h" #include "URL.h" #include "profiles/ProfilesManager.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "GUIUserMessages.h" #include "FileItem.h" #include "guilib/GUIWindowManager.h" @@ -467,7 +467,7 @@ CUPnP::StartClient() m_MediaBrowser = new CMediaBrowser(m_CtrlPointHolder->m_CtrlPoint); // start controller - if (g_guiSettings.GetBool("services.upnpcontroller")) { + if (CSettings::Get().GetBool("services.upnpcontroller")) { m_MediaController = new CMediaController(m_CtrlPointHolder->m_CtrlPoint); } } @@ -504,7 +504,7 @@ CUPnP::CreateServer(int port /* = 0 */) // but it doesn't work anyways as it requires multicast for XP to detect us device->m_PresentationURL = NPT_HttpUrl(m_IP, - atoi(g_guiSettings.GetString("services.webserverport")), + CSettings::Get().GetInt("services.webserverport"), "/").ToString(); device->m_ModelName = "XBMC Media Center"; @@ -521,12 +521,12 @@ CUPnP::CreateServer(int port /* = 0 */) /*---------------------------------------------------------------------- | CUPnP::StartServer +---------------------------------------------------------------------*/ -void +bool CUPnP::StartServer() { - if (!m_ServerHolder->m_Device.IsNull()) return; + if (!m_ServerHolder->m_Device.IsNull()) return false; - // load upnpserver.xml so that g_settings.m_vecUPnPMusiCMediaSources, etc.. are loaded + // load upnpserver.xml CStdString filename; URIUtils::AddFileToFolder(CProfilesManager::Get().GetUserDataFolder(), "upnpserver.xml", filename); CUPnPSettings::Get().Load(filename); @@ -559,7 +559,7 @@ CUPnP::StartServer() // save UUID CUPnPSettings::Get().SetServerUUID(m_ServerHolder->m_Device->GetUUID().GetChars()); - CUPnPSettings::Get().Save(filename); + return CUPnPSettings::Get().Save(filename); } /*---------------------------------------------------------------------- @@ -588,7 +588,7 @@ CUPnP::CreateRenderer(int port /* = 0 */) device->m_PresentationURL = NPT_HttpUrl(m_IP, - atoi(g_guiSettings.GetString("services.webserverport")), + CSettings::Get().GetInt("services.webserverport"), "/").ToString(); device->m_ModelName = "XBMC Media Center"; device->m_ModelNumber = g_infoManager.GetVersion().c_str(); @@ -603,9 +603,9 @@ CUPnP::CreateRenderer(int port /* = 0 */) /*---------------------------------------------------------------------- | CUPnP::StartRenderer +---------------------------------------------------------------------*/ -void CUPnP::StartRenderer() +bool CUPnP::StartRenderer() { - if (!m_RendererHolder->m_Device.IsNull()) return; + if (!m_RendererHolder->m_Device.IsNull()) return false; CStdString filename; URIUtils::AddFileToFolder(CProfilesManager::Get().GetUserDataFolder(), "upnpserver.xml", filename); @@ -629,7 +629,7 @@ void CUPnP::StartRenderer() // save UUID CUPnPSettings::Get().SetRendererUUID(m_RendererHolder->m_Device->GetUUID().GetChars()); - CUPnPSettings::Get().Save(filename); + return CUPnPSettings::Get().Save(filename); } /*---------------------------------------------------------------------- diff --git a/xbmc/network/upnp/UPnP.h b/xbmc/network/upnp/UPnP.h index eda10c470a249..c55f76579de9c 100644 --- a/xbmc/network/upnp/UPnP.h +++ b/xbmc/network/upnp/UPnP.h @@ -49,7 +49,7 @@ class CUPnP ~CUPnP(); // server - void StartServer(); + bool StartServer(); void StopServer(); // client @@ -58,7 +58,7 @@ class CUPnP bool IsClientStarted() { return (m_MediaBrowser != NULL); } // renderer - void StartRenderer(); + bool StartRenderer(); void StopRenderer(); void UpdateState(); diff --git a/xbmc/network/upnp/UPnPServer.cpp b/xbmc/network/upnp/UPnPServer.cpp index 3ab77aea62c2e..58fd2910aa95d 100644 --- a/xbmc/network/upnp/UPnPServer.cpp +++ b/xbmc/network/upnp/UPnPServer.cpp @@ -14,7 +14,7 @@ #include "guilib/WindowIDs.h" #include "music/tags/MusicInfoTag.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/log.h" #include "utils/md5.h" #include "utils/StringUtils.h" @@ -137,7 +137,7 @@ CUPnPServer::PropagateUpdates() string buffer; map >::iterator itr; - if (m_scanning || !g_guiSettings.GetBool("services.upnpannounce")) + if (m_scanning || !CSettings::Get().GetBool("services.upnpannounce")) return; NPT_CHECK_LABEL(FindServiceById("urn:upnp-org:serviceId:ContentDirectory", service), failed); diff --git a/xbmc/osx/IOSScreenManager.mm b/xbmc/osx/IOSScreenManager.mm index 1582fadae44b9..d393f11d38736 100644 --- a/xbmc/osx/IOSScreenManager.mm +++ b/xbmc/osx/IOSScreenManager.mm @@ -28,7 +28,7 @@ #include "threads/Event.h" #include "Application.h" #include "WindowingFactory.h" -#include "Settings.h" +#include "settings/DisplaySettings.h" #undef BOOL #import diff --git a/xbmc/osx/XBMCHelper.cpp b/xbmc/osx/XBMCHelper.cpp index 17e46e3e4112e..434ff8f2e354c 100644 --- a/xbmc/osx/XBMCHelper.cpp +++ b/xbmc/osx/XBMCHelper.cpp @@ -28,9 +28,11 @@ #include "PlatformDefs.h" #include "Util.h" +#include "dialogs/GUIDialogOK.h" +#include "dialogs/GUIDialogYesNo.h" #include "utils/log.h" #include "system.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/SystemInfo.h" #include "threads/Atomics.h" @@ -87,6 +89,50 @@ XBMCHelper::XBMCHelper() m_configFile += "/Library/Application Support/XBMC/XBMCHelper.conf"; } +///////////////////////////////////////////////////////////////////////////// +bool XBMCHelper::OnSettingChanging(const CSetting *setting) +{ + if (setting == NULL) + return false; + + const std::string &settingId = setting->GetId(); + if (settingId == "input.appleremotemode") + { + int remoteMode = ((CSettingInt*)setting)->GetValue(); + + // if it's not disabled, start the event server or else apple remote won't work + if (remoteMode != APPLE_REMOTE_DISABLED) + { + // if starting the event server fails, we have to revert the change + if (!CSettings::Get().SetBool("services.esenabled", true)) + return false; + } + + // if XBMC helper is running, prompt user before effecting change + if (IsRunning() && GetMode() != remoteMode) + { + bool cancelled; + if (!CGUIDialogYesNo::ShowAndGetInput(13144, 13145, 13146, 13147, -1, -1, cancelled, 10000)) + return false; + // reload configuration + else + Configure(); + } + // set new configuration. + else + Configure(); + + if (ErrorStarting() == true) + { + // inform user about error + CGUIDialogOK::ShowAndGetInput(13620, 13621, 20022, 20022); + return false; + } + } + + return true; +} + ///////////////////////////////////////////////////////////////////////////// void XBMCHelper::Start() { @@ -123,10 +169,10 @@ void XBMCHelper::Configure() // Read the new configuration. m_errorStarting = false; - m_mode = g_guiSettings.GetInt("input.appleremotemode"); - m_sequenceDelay = g_guiSettings.GetInt("input.appleremotesequencetime"); - m_alwaysOn = g_guiSettings.GetBool("input.appleremotealwayson"); - CStdString port_string = g_guiSettings.GetString("services.esport"); + m_mode = CSettings::Get().GetInt("input.appleremotemode"); + m_sequenceDelay = CSettings::Get().GetInt("input.appleremotesequencetime"); + m_alwaysOn = CSettings::Get().GetBool("input.appleremotealwayson"); + CStdString port_string = CSettings::Get().GetString("services.esport"); m_port = atoi(port_string.c_str()); @@ -138,7 +184,7 @@ void XBMCHelper::Configure() m_errorStarting = true; m_mode = APPLE_REMOTE_DISABLED; - g_guiSettings.SetInt("input.appleremotemode", APPLE_REMOTE_DISABLED); + CSettings::Get().SetInt("input.appleremotemode", APPLE_REMOTE_DISABLED); } // New configuration. diff --git a/xbmc/osx/XBMCHelper.h b/xbmc/osx/XBMCHelper.h index da9c86eb07769..ba70f00bdb52e 100644 --- a/xbmc/osx/XBMCHelper.h +++ b/xbmc/osx/XBMCHelper.h @@ -22,12 +22,24 @@ */ #if !defined(__arm__) -class XBMCHelper + +#include "settings/ISettingCallback.h" + +enum AppleRemoteOptions { - public: + APPLE_REMOTE_DISABLED = 0, + APPLE_REMOTE_STANDARD, + APPLE_REMOTE_UNIVERSAL, + APPLE_REMOTE_MULTIREMOTE +}; +class XBMCHelper : public ISettingCallback +{ + public: static XBMCHelper& GetInstance(); + virtual bool OnSettingChanging(const CSetting *setting); + void Start(); void Stop(); diff --git a/xbmc/peripherals/Peripherals.cpp b/xbmc/peripherals/Peripherals.cpp index 9188b25a737a2..b9f066cf6f302 100644 --- a/xbmc/peripherals/Peripherals.cpp +++ b/xbmc/peripherals/Peripherals.cpp @@ -38,7 +38,6 @@ #include "threads/SingleLock.h" #include "utils/log.h" #include "utils/XMLUtils.h" -#include "settings/GUISettings.h" #include "utils/XBMCTinyXML.h" #include "filesystem/Directory.h" #include "guilib/GUIWindowManager.h" @@ -48,6 +47,7 @@ #include "utils/StringUtils.h" #include "Util.h" #include "guilib/Key.h" +#include "settings/Setting.h" using namespace PERIPHERALS; using namespace XFILE; @@ -55,8 +55,6 @@ using namespace std; CPeripherals::CPeripherals(void) { - CDirectory::Create("special://profile/peripheral_data"); - Clear(); } @@ -78,6 +76,8 @@ void CPeripherals::Initialise(void) { m_bIsStarted = true; + CDirectory::Create("special://profile/peripheral_data"); + /* load mappings from peripherals.xml */ LoadMappings(); @@ -462,8 +462,6 @@ bool CPeripherals::LoadMappings(void) void CPeripherals::GetSettingsFromMappingsFile(TiXmlElement *xmlNode, map &m_settings) { TiXmlElement *currentNode = xmlNode->FirstChildElement("setting"); - int iMaxOrder(0); - while (currentNode) { CSetting *setting = NULL; @@ -483,7 +481,7 @@ void CPeripherals::GetSettingsFromMappingsFile(TiXmlElement *xmlNode, mapAttribute("value"), "no") != 0 && strcmp(currentNode->Attribute("value"), "false") != 0 && strcmp(currentNode->Attribute("value"), "0") != 0); - setting = new CSettingBool(0, strKey, iLabelId, bValue, CHECKMARK_CONTROL); + setting = new CSettingBool(strKey, iLabelId, bValue); } else if (strSettingsType.Equals("int")) { @@ -492,7 +490,7 @@ void CPeripherals::GetSettingsFromMappingsFile(TiXmlElement *xmlNode, mapAttribute("step") ? atoi(currentNode->Attribute("step")) : 1; int iMax = currentNode->Attribute("max") ? atoi(currentNode->Attribute("max")) : 255; CStdString strFormat(currentNode->Attribute("format")); - setting = new CSettingInt(0, strKey, iLabelId, iValue, iMin, iStep, iMax, SPIN_CONTROL_INT, strFormat); + setting = new CSettingInt(strKey, iLabelId, iValue, iMin, iStep, iMax, strFormat); } else if (strSettingsType.Equals("float")) { @@ -500,26 +498,26 @@ void CPeripherals::GetSettingsFromMappingsFile(TiXmlElement *xmlNode, mapAttribute("min") ? (float) atof(currentNode->Attribute("min")) : 0; float fStep = currentNode->Attribute("step") ? (float) atof(currentNode->Attribute("step")) : 0; float fMax = currentNode->Attribute("max") ? (float) atof(currentNode->Attribute("max")) : 0; - setting = new CSettingFloat(0, strKey, iLabelId, fValue, fMin, fStep, fMax, SPIN_CONTROL_FLOAT); + setting = new CSettingNumber(strKey, iLabelId, fValue, fMin, fStep, fMax); } else if (strSettingsType.Equals("enum")) { CStdString strEnums(currentNode->Attribute("lvalues")); if (!strEnums.IsEmpty()) { - map enums; + vector< pair > enums; vector valuesVec; CUtil::Tokenize(strEnums, valuesVec, "|"); for (unsigned int i = 0; i < valuesVec.size(); i++) - enums.insert(make_pair(atoi(valuesVec[i]), atoi(valuesVec[i]))); + enums.push_back(make_pair(atoi(valuesVec[i]), atoi(valuesVec[i]))); int iValue = currentNode->Attribute("value") ? atoi(currentNode->Attribute("value")) : 0; - setting = new CSettingInt(0, strKey, iLabelId, iValue, enums, SPIN_CONTROL_TEXT); + setting = new CSettingInt(strKey, iLabelId, iValue, enums); } } else { CStdString strValue(currentNode->Attribute("value")); - setting = new CSettingString(0, strKey, iLabelId, strValue, EDIT_CONTROL_INPUT, !bConfigurable, -1); + setting = new CSettingString(strKey, iLabelId, strValue); } if (setting) @@ -529,29 +527,12 @@ void CPeripherals::GetSettingsFromMappingsFile(TiXmlElement *xmlNode, mapSetVisible(bConfigurable); - /* set the order */ - int iOrder(0); - currentNode->Attribute("order", &iOrder); - /* if the order attribute is invalid or 0, then the setting will be added at the end */ - if (iOrder < 0) - iOrder = 0; - setting->SetOrder(iOrder); - if (iOrder > iMaxOrder) - iMaxOrder = iOrder; - /* and add this new setting */ m_settings[strKey] = setting; } currentNode = currentNode->NextSiblingElement("setting"); } - - /* add the settings without an order attribute or an invalid order attribute set at the end */ - for (map::iterator it = m_settings.begin(); it != m_settings.end(); it++) - { - if (it->second->GetOrder() == 0) - it->second->SetOrder(++iMaxOrder); - } } void CPeripherals::GetDirectory(const CStdString &strPath, CFileItemList &items) const @@ -673,3 +654,35 @@ bool CPeripherals::GetNextKeypress(float frameTime, CKey &key) return false; } + +void CPeripherals::OnSettingChanged(const CSetting *setting) +{ + if (setting == NULL) + return; + + const std::string &settingId = setting->GetId(); + if (settingId == "locale.language") + { + // user set language, no longer use the TV's language + vector cecDevices; + if (g_peripherals.GetPeripheralsWithFeature(cecDevices, FEATURE_CEC) > 0) + { + for (vector::iterator it = cecDevices.begin(); it != cecDevices.end(); it++) + (*it)->SetSetting("use_tv_menu_language", false); + } + } +} + +void CPeripherals::OnSettingAction(const CSetting *setting) +{ + if (setting == NULL) + return; + + const std::string &settingId = setting->GetId(); + if (settingId == "input.peripherals") + { + CGUIDialogPeripheralManager *dialog = (CGUIDialogPeripheralManager *)g_windowManager.GetWindow(WINDOW_DIALOG_PERIPHERAL_MANAGER); + if (dialog != NULL) + dialog->DoModal(); + } +} diff --git a/xbmc/peripherals/Peripherals.h b/xbmc/peripherals/Peripherals.h index e2120493fd7c0..1e93b3dc54492 100644 --- a/xbmc/peripherals/Peripherals.h +++ b/xbmc/peripherals/Peripherals.h @@ -22,6 +22,7 @@ #include "system.h" #include "bus/PeripheralBus.h" #include "devices/Peripheral.h" +#include "settings/ISettingCallback.h" #include "threads/CriticalSection.h" #include "threads/Thread.h" @@ -36,7 +37,7 @@ namespace PERIPHERALS { #define g_peripherals CPeripherals::Get() - class CPeripherals + class CPeripherals : public ISettingCallback { public: static CPeripherals &Get(void); @@ -195,6 +196,9 @@ namespace PERIPHERALS return false; #endif } + + virtual void OnSettingChanged(const CSetting *setting); + virtual void OnSettingAction(const CSetting *setting); private: CPeripherals(void); diff --git a/xbmc/peripherals/devices/Peripheral.cpp b/xbmc/peripherals/devices/Peripheral.cpp index 03bd167a1f767..084dea0d84039 100644 --- a/xbmc/peripherals/devices/Peripheral.cpp +++ b/xbmc/peripherals/devices/Peripheral.cpp @@ -22,7 +22,7 @@ #include "peripherals/Peripherals.h" #include "utils/log.h" #include "utils/StringUtils.h" -#include "settings/GUISettings.h" +#include "settings/Setting.h" #include "utils/XBMCTinyXML.h" #include "utils/URIUtils.h" #include "guilib/LocalizeStrings.h" @@ -30,14 +30,6 @@ using namespace PERIPHERALS; using namespace std; -struct SortBySettingsOrder -{ - bool operator()(const CSetting *left, const CSetting *right) - { - return left->GetOrder() < right->GetOrder(); - } -}; - CPeripheral::CPeripheral(const PeripheralScanResult& scanResult) : m_type(scanResult.m_mappedType), m_busType(scanResult.m_busType), @@ -168,7 +160,6 @@ vector CPeripheral::GetSettings(void) const vector settings; for (map::const_iterator it = m_settings.begin(); it != m_settings.end(); it++) settings.push_back(it->second); - sort(settings.begin(), settings.end(), SortBySettingsOrder()); return settings; } @@ -184,10 +175,10 @@ void CPeripheral::AddSetting(const CStdString &strKey, const CSetting *setting) { switch(setting->GetType()) { - case SETTINGS_TYPE_BOOL: + case SettingTypeBool: { const CSettingBool *mappedSetting = (const CSettingBool *) setting; - CSettingBool *boolSetting = new CSettingBool(mappedSetting->GetOrder(), strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData(), mappedSetting->GetControlType()); + CSettingBool *boolSetting = new CSettingBool(strKey, *mappedSetting); if (boolSetting) { boolSetting->SetVisible(mappedSetting->IsVisible()); @@ -195,18 +186,10 @@ void CPeripheral::AddSetting(const CStdString &strKey, const CSetting *setting) } } break; - case SETTINGS_TYPE_INT: + case SettingTypeInteger: { const CSettingInt *mappedSetting = (const CSettingInt *) setting; - CSettingInt *intSetting(NULL); - if (mappedSetting->GetControlType() == SPIN_CONTROL_INT) - { - intSetting = new CSettingInt(mappedSetting->GetOrder(), strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData(), mappedSetting->m_iMin, mappedSetting->m_iStep, mappedSetting->m_iMax, mappedSetting->GetControlType(), mappedSetting->m_strFormat); - } - else if (mappedSetting->GetControlType() == SPIN_CONTROL_TEXT) - { - intSetting = new CSettingInt(mappedSetting->GetOrder(), strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData(), mappedSetting->m_entries, mappedSetting->GetControlType()); - } + CSettingInt *intSetting = new CSettingInt(strKey, *mappedSetting); if (intSetting) { intSetting->SetVisible(mappedSetting->IsVisible()); @@ -214,10 +197,10 @@ void CPeripheral::AddSetting(const CStdString &strKey, const CSetting *setting) } } break; - case SETTINGS_TYPE_FLOAT: + case SettingTypeNumber: { - const CSettingFloat *mappedSetting = (const CSettingFloat *) setting; - CSettingFloat *floatSetting = new CSettingFloat(mappedSetting->GetOrder(), strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData(), mappedSetting->m_fMin, mappedSetting->m_fStep, mappedSetting->m_fMax, mappedSetting->GetControlType()); + const CSettingNumber *mappedSetting = (const CSettingNumber *) setting; + CSettingNumber *floatSetting = new CSettingNumber(strKey, *mappedSetting); if (floatSetting) { floatSetting->SetVisible(mappedSetting->IsVisible()); @@ -225,10 +208,10 @@ void CPeripheral::AddSetting(const CStdString &strKey, const CSetting *setting) } } break; - case SETTINGS_TYPE_STRING: + case SettingTypeString: { const CSettingString *mappedSetting = (const CSettingString *) setting; - CSettingString *stringSetting = new CSettingString(mappedSetting->GetOrder(), strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData().c_str(), mappedSetting->GetControlType(), mappedSetting->m_bAllowEmpty, mappedSetting->m_iHeadingString); + CSettingString *stringSetting = new CSettingString(strKey, *mappedSetting); if (stringSetting) { stringSetting->SetVisible(mappedSetting->IsVisible()); @@ -275,11 +258,11 @@ bool CPeripheral::HasConfigurableSettings(void) const bool CPeripheral::GetSettingBool(const CStdString &strKey) const { map::const_iterator it = m_settings.find(strKey); - if (it != m_settings.end() && (*it).second->GetType() == SETTINGS_TYPE_BOOL) + if (it != m_settings.end() && (*it).second->GetType() == SettingTypeBool) { - CSettingBool *boolSetting = (CSettingBool *) (*it).second; + CSettingBool *boolSetting = (CSettingBool *) (*it).second; if (boolSetting) - return boolSetting->GetData(); + return boolSetting->GetValue(); } return false; @@ -288,11 +271,11 @@ bool CPeripheral::GetSettingBool(const CStdString &strKey) const int CPeripheral::GetSettingInt(const CStdString &strKey) const { map::const_iterator it = m_settings.find(strKey); - if (it != m_settings.end() && (*it).second->GetType() == SETTINGS_TYPE_INT) + if (it != m_settings.end() && (*it).second->GetType() == SettingTypeInteger) { - CSettingInt *intSetting = (CSettingInt *) (*it).second; + CSettingInt *intSetting = (CSettingInt *) (*it).second; if (intSetting) - return intSetting->GetData(); + return intSetting->GetValue(); } return 0; @@ -301,11 +284,11 @@ int CPeripheral::GetSettingInt(const CStdString &strKey) const float CPeripheral::GetSettingFloat(const CStdString &strKey) const { map::const_iterator it = m_settings.find(strKey); - if (it != m_settings.end() && (*it).second->GetType() == SETTINGS_TYPE_FLOAT) + if (it != m_settings.end() && (*it).second->GetType() == SettingTypeNumber) { - CSettingFloat *floatSetting = (CSettingFloat *) (*it).second; + CSettingNumber *floatSetting = (CSettingNumber *) (*it).second; if (floatSetting) - return floatSetting->GetData(); + return (float)floatSetting->GetValue(); } return 0; @@ -314,11 +297,11 @@ float CPeripheral::GetSettingFloat(const CStdString &strKey) const const CStdString CPeripheral::GetSettingString(const CStdString &strKey) const { map::const_iterator it = m_settings.find(strKey); - if (it != m_settings.end() && (*it).second->GetType() == SETTINGS_TYPE_STRING) + if (it != m_settings.end() && (*it).second->GetType() == SettingTypeString) { - CSettingString *stringSetting = (CSettingString *) (*it).second; + CSettingString *stringSetting = (CSettingString *) (*it).second; if (stringSetting) - return stringSetting->GetData(); + return stringSetting->GetValue(); } return StringUtils::EmptyString; @@ -328,13 +311,13 @@ bool CPeripheral::SetSetting(const CStdString &strKey, bool bValue) { bool bChanged(false); map::iterator it = m_settings.find(strKey); - if (it != m_settings.end() && (*it).second->GetType() == SETTINGS_TYPE_BOOL) + if (it != m_settings.end() && (*it).second->GetType() == SettingTypeBool) { - CSettingBool *boolSetting = (CSettingBool *) (*it).second; + CSettingBool *boolSetting = (CSettingBool *) (*it).second; if (boolSetting) { - bChanged = boolSetting->GetData() != bValue; - boolSetting->SetData(bValue); + bChanged = boolSetting->GetValue() != bValue; + boolSetting->SetValue(bValue); if (bChanged && m_bInitialised) m_changedSettings.insert(strKey); } @@ -346,13 +329,13 @@ bool CPeripheral::SetSetting(const CStdString &strKey, int iValue) { bool bChanged(false); map::iterator it = m_settings.find(strKey); - if (it != m_settings.end() && (*it).second->GetType() == SETTINGS_TYPE_INT) + if (it != m_settings.end() && (*it).second->GetType() == SettingTypeInteger) { - CSettingInt *intSetting = (CSettingInt *) (*it).second; + CSettingInt *intSetting = (CSettingInt *) (*it).second; if (intSetting) { - bChanged = intSetting->GetData() != iValue; - intSetting->SetData(iValue); + bChanged = intSetting->GetValue() != iValue; + intSetting->SetValue(iValue); if (bChanged && m_bInitialised) m_changedSettings.insert(strKey); } @@ -364,13 +347,13 @@ bool CPeripheral::SetSetting(const CStdString &strKey, float fValue) { bool bChanged(false); map::iterator it = m_settings.find(strKey); - if (it != m_settings.end() && (*it).second->GetType() == SETTINGS_TYPE_FLOAT) + if (it != m_settings.end() && (*it).second->GetType() == SettingTypeNumber) { - CSettingFloat *floatSetting = (CSettingFloat *) (*it).second; + CSettingNumber *floatSetting = (CSettingNumber *) (*it).second; if (floatSetting) { - bChanged = floatSetting->GetData() != fValue; - floatSetting->SetData(fValue); + bChanged = floatSetting->GetValue() != fValue; + floatSetting->SetValue(fValue); if (bChanged && m_bInitialised) m_changedSettings.insert(strKey); } @@ -399,22 +382,22 @@ bool CPeripheral::SetSetting(const CStdString &strKey, const CStdString &strValu map::iterator it = m_settings.find(strKey); if (it != m_settings.end()) { - if ((*it).second->GetType() == SETTINGS_TYPE_STRING) + if ((*it).second->GetType() == SettingTypeString) { - CSettingString *stringSetting = (CSettingString *) (*it).second; + CSettingString *stringSetting = (CSettingString *) (*it).second; if (stringSetting) { - bChanged = !stringSetting->GetData().Equals(strValue); - stringSetting->SetData(strValue); + bChanged = !StringUtils::EqualsNoCase(stringSetting->GetValue(), strValue); + stringSetting->SetValue(strValue); if (bChanged && m_bInitialised) m_changedSettings.insert(strKey); } } - else if ((*it).second->GetType() == SETTINGS_TYPE_INT) + else if ((*it).second->GetType() == SettingTypeInteger) bChanged = SetSetting(strKey, (int) (strValue.IsEmpty() ? 0 : atoi(strValue.c_str()))); - else if ((*it).second->GetType() == SETTINGS_TYPE_FLOAT) + else if ((*it).second->GetType() == SettingTypeNumber) bChanged = SetSetting(strKey, (float) (strValue.IsEmpty() ? 0 : atof(strValue.c_str()))); - else if ((*it).second->GetType() == SETTINGS_TYPE_BOOL) + else if ((*it).second->GetType() == SettingTypeBool) bChanged = SetSetting(strKey, strValue.Equals("1")); } return bChanged; @@ -432,32 +415,32 @@ void CPeripheral::PersistSettings(bool bExiting /* = false */) CStdString strValue; switch ((*itr).second->GetType()) { - case SETTINGS_TYPE_STRING: + case SettingTypeString: { CSettingString *stringSetting = (CSettingString *) (*itr).second; if (stringSetting) - strValue = stringSetting->GetData(); + strValue = stringSetting->GetValue(); } break; - case SETTINGS_TYPE_INT: + case SettingTypeInteger: { CSettingInt *intSetting = (CSettingInt *) (*itr).second; if (intSetting) - strValue.Format("%d", intSetting->GetData()); + strValue.Format("%d", intSetting->GetValue()); } break; - case SETTINGS_TYPE_FLOAT: + case SettingTypeNumber: { - CSettingFloat *floatSetting = (CSettingFloat *) (*itr).second; + CSettingNumber *floatSetting = (CSettingNumber *) (*itr).second; if (floatSetting) - strValue.Format("%.2f", floatSetting->GetData()); + strValue.Format("%.2f", floatSetting->GetValue()); } break; - case SETTINGS_TYPE_BOOL: + case SettingTypeBool: { CSettingBool *boolSetting = (CSettingBool *) (*itr).second; if (boolSetting) - strValue.Format("%d", boolSetting->GetData() ? 1:0); + strValue.Format("%d", boolSetting->GetValue() ? 1:0); } break; default: diff --git a/xbmc/peripherals/devices/Peripheral.h b/xbmc/peripherals/devices/Peripheral.h index 443f91d9aac29..51f6c566c3c04 100644 --- a/xbmc/peripherals/devices/Peripheral.h +++ b/xbmc/peripherals/devices/Peripheral.h @@ -25,6 +25,8 @@ class TiXmlDocument; +class CSetting; + namespace PERIPHERALS { class CGUIDialogPeripheralSettings; diff --git a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp index 5cc7064d00b25..386d3e4165d00 100644 --- a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp +++ b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp @@ -33,7 +33,7 @@ #include "peripherals/Peripherals.h" #include "peripherals/bus/PeripheralBus.h" #include "pictures/GUIWindowSlideShow.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/log.h" #include "utils/Variant.h" diff --git a/xbmc/peripherals/devices/PeripheralImon.cpp b/xbmc/peripherals/devices/PeripheralImon.cpp index 1f2b0347060f5..36532b8cd62eb 100644 --- a/xbmc/peripherals/devices/PeripheralImon.cpp +++ b/xbmc/peripherals/devices/PeripheralImon.cpp @@ -21,8 +21,8 @@ #include "PeripheralImon.h" #include "utils/log.h" #include "guilib/LocalizeStrings.h" +#include "settings/Settings.h" #include "threads/Atomics.h" -#include "settings/GUISettings.h" #if defined (TARGET_WINDOWS) #include "system.h" // For HAS_SDL_JOYSTICK #if defined (HAS_SDL_JOYSTICK) @@ -106,8 +106,8 @@ void CPeripheralImon::ActionOnImonConflict(bool deviceInserted /*= true*/) { if (deviceInserted || m_lCountOfImonsConflictWithDInput == 0) { -#if defined(TARGET_WINDOWS) && defined(HAS_SDL_JOYSTICK) - bool enableJoystickNow = !deviceInserted && g_guiSettings.GetBool("input.enablejoystick"); +#if defined(TARGET_WINDOWS) && defined (HAS_SDL_JOYSTICK) + bool enableJoystickNow = !deviceInserted && CSettings::Get().GetBool("input.enablejoystick"); CLog::Log(LOGNOTICE, "Problematic iMON hardware %s. Joystick usage: %s", (deviceInserted ? "detected" : "was removed"), (enableJoystickNow) ? "enabled." : "disabled." ); g_Joystick.SetEnabled(enableJoystickNow); diff --git a/xbmc/peripherals/devices/PeripheralImon.h b/xbmc/peripherals/devices/PeripheralImon.h index f8e40ffb88aca..a9db31b9d74e1 100644 --- a/xbmc/peripherals/devices/PeripheralImon.h +++ b/xbmc/peripherals/devices/PeripheralImon.h @@ -21,6 +21,8 @@ #include "PeripheralHID.h" +class CSetting; + namespace PERIPHERALS { class CPeripheralImon : public CPeripheralHID diff --git a/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.cpp b/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.cpp index da3517d78b513..5dd3e83dcfd66 100644 --- a/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.cpp +++ b/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.cpp @@ -21,7 +21,7 @@ #include "GUIDialogPeripheralSettings.h" #include "addons/Skin.h" #include "peripherals/Peripherals.h" -#include "settings/GUISettings.h" +#include "settings/Setting.h" #include "utils/log.h" #include "video/dialogs/GUIDialogVideoSettings.h" @@ -33,7 +33,8 @@ using namespace PERIPHERALS; CGUIDialogPeripheralSettings::CGUIDialogPeripheralSettings(void) : CGUIDialogSettings(WINDOW_DIALOG_PERIPHERAL_SETTINGS, "DialogPeripheralSettings.xml"), m_item(NULL), - m_bIsInitialising(true) + m_bIsInitialising(true), + m_settingId(0) { } @@ -81,58 +82,58 @@ void CGUIDialogPeripheralSettings::CreateSettings() switch(setting->GetType()) { - case SETTINGS_TYPE_BOOL: + case SettingTypeBool: { CSettingBool *boolSetting = (CSettingBool *) setting; if (boolSetting) { - m_boolSettings.insert(make_pair(CStdString(boolSetting->GetSetting()), boolSetting->GetData())); - AddBool(boolSetting->GetOrder(), boolSetting->GetLabel(), &m_boolSettings[boolSetting->GetSetting()], true); + m_boolSettings.insert(make_pair(CStdString(boolSetting->GetId()), boolSetting->GetValue())); + AddBool(m_settingId++, boolSetting->GetLabel(), &m_boolSettings[boolSetting->GetId()], true); } } break; - case SETTINGS_TYPE_INT: + case SettingTypeInteger: { CSettingInt *intSetting = (CSettingInt *) setting; if (intSetting) { - if (intSetting->GetControlType() == SPIN_CONTROL_INT) + if (intSetting->GetControl().GetFormat() == SettingControlFormatInteger) { - m_intSettings.insert(make_pair(CStdString(intSetting->GetSetting()), (float) intSetting->GetData())); - AddSlider(intSetting->GetOrder(), intSetting->GetLabel(), &m_intSettings[intSetting->GetSetting()], (float)intSetting->m_iMin, (float)intSetting->m_iStep, (float)intSetting->m_iMax, CGUIDialogVideoSettings::FormatInteger, false); + m_intSettings.insert(make_pair(CStdString(intSetting->GetId()), (float) intSetting->GetValue())); + AddSlider(m_settingId++, intSetting->GetLabel(), &m_intSettings[intSetting->GetId()], (float)intSetting->GetMinimum(), (float)intSetting->GetStep(), (float)intSetting->GetMaximum(), CGUIDialogVideoSettings::FormatInteger, false); } - else if (intSetting->GetControlType() == SPIN_CONTROL_TEXT) + else if (intSetting->GetControl().GetFormat() == SettingControlFormatString) { - m_intTextSettings.insert(make_pair(CStdString(intSetting->GetSetting()), intSetting->GetData())); + m_intTextSettings.insert(make_pair(CStdString(intSetting->GetId()), intSetting->GetValue())); vector > entries; - map::iterator entriesItr = intSetting->m_entries.begin(); - while (entriesItr != intSetting->m_entries.end()) + SettingOptions::const_iterator entriesItr = intSetting->GetOptions().begin(); + while (entriesItr != intSetting->GetOptions().end()) { entries.push_back(make_pair(entriesItr->first, entriesItr->second)); ++entriesItr; } - AddSpin(intSetting->GetOrder(), intSetting->GetLabel(), &m_intTextSettings[intSetting->GetSetting()], entries); + AddSpin(m_settingId++, intSetting->GetLabel(), &m_intTextSettings[intSetting->GetId()], entries); } } } break; - case SETTINGS_TYPE_FLOAT: + case SettingTypeNumber: { - CSettingFloat *floatSetting = (CSettingFloat *) setting; + CSettingNumber *floatSetting = (CSettingNumber *) setting; if (floatSetting) { - m_floatSettings.insert(make_pair(CStdString(floatSetting->GetSetting()), floatSetting->GetData())); - AddSlider(floatSetting->GetOrder(), floatSetting->GetLabel(), &m_floatSettings[floatSetting->GetSetting()], floatSetting->m_fMin, floatSetting->m_fStep, floatSetting->m_fMax, CGUIDialogVideoSettings::FormatFloat, false); + m_floatSettings.insert(make_pair(CStdString(floatSetting->GetId()), (float)floatSetting->GetValue())); + AddSlider(m_settingId++, floatSetting->GetLabel(), &m_floatSettings[floatSetting->GetId()], (float)floatSetting->GetMinimum(), (float)floatSetting->GetStep(), (float)floatSetting->GetMaximum(), CGUIDialogVideoSettings::FormatFloat, false); } } break; - case SETTINGS_TYPE_STRING: + case SettingTypeString: { CSettingString *stringSetting = (CSettingString *) setting; if (stringSetting) { - m_stringSettings.insert(make_pair(CStdString(stringSetting->GetSetting()), stringSetting->GetData())); - AddString(stringSetting->GetOrder(), stringSetting->GetLabel(), &m_stringSettings[stringSetting->GetSetting()]); + m_stringSettings.insert(make_pair(CStdString(stringSetting->GetId()), stringSetting->GetValue())); + AddString(m_settingId++, stringSetting->GetLabel(), &m_stringSettings[stringSetting->GetId()]); } } break; diff --git a/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.h b/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.h index 6c8fc812f992e..4471f9359b906 100644 --- a/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.h +++ b/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.h @@ -46,5 +46,6 @@ namespace PERIPHERALS std::map m_intTextSettings; std::map m_floatSettings; std::map m_stringSettings; + int m_settingId; }; } diff --git a/xbmc/pictures/GUIViewStatePictures.cpp b/xbmc/pictures/GUIViewStatePictures.cpp index a801e1c324b81..2dfe6fbde0fbc 100644 --- a/xbmc/pictures/GUIViewStatePictures.cpp +++ b/xbmc/pictures/GUIViewStatePictures.cpp @@ -21,9 +21,9 @@ #include "GUIViewStatePictures.h" #include "FileItem.h" #include "view/ViewState.h" -#include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" #include "settings/MediaSourceSettings.h" +#include "settings/Settings.h" #include "filesystem/Directory.h" #include "filesystem/PluginDirectory.h" #include "guilib/LocalizeStrings.h" @@ -52,8 +52,8 @@ 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 - - CViewState *viewState = CViewStateSettings::Get().Get("pictures"); + + const CViewState *viewState = CViewStateSettings::Get().Get("pictures"); SetSortMethod(viewState->m_sortMethod); SetViewAsControl(viewState->m_viewMode); SetSortOrder(viewState->m_sortOrder); @@ -73,7 +73,7 @@ CStdString CGUIViewStateWindowPictures::GetLockType() CStdString CGUIViewStateWindowPictures::GetExtensions() { - if (g_guiSettings.GetBool("pictures.showvideos")) + if (CSettings::Get().GetBool("pictures.showvideos")) return g_advancedSettings.m_pictureExtensions+"|"+g_advancedSettings.m_videoExtensions; return g_advancedSettings.m_pictureExtensions; diff --git a/xbmc/pictures/GUIWindowPictures.cpp b/xbmc/pictures/GUIWindowPictures.cpp index e54450b8fc7df..893173d672df2 100644 --- a/xbmc/pictures/GUIWindowPictures.cpp +++ b/xbmc/pictures/GUIWindowPictures.cpp @@ -36,9 +36,8 @@ #include "dialogs/GUIDialogOK.h" #include "dialogs/GUIDialogYesNo.h" #include "playlists/PlayList.h" -#include "settings/Settings.h" -#include "settings/GUISettings.h" #include "settings/MediaSourceSettings.h" +#include "settings/Settings.h" #include "utils/TimeUtils.h" #include "utils/log.h" #include "utils/URIUtils.h" @@ -137,8 +136,8 @@ bool CGUIWindowPictures::OnMessage(CGUIMessage& message) } else if (iControl == CONTROL_SHUFFLE) { - g_guiSettings.ToggleBool("slideshow.shuffle"); - g_settings.Save(); + CSettings::Get().ToggleBool("slideshow.shuffle"); + CSettings::Get().Save(); } else if (m_viewControl.HasControl(iControl)) // list/thumb control { @@ -149,7 +148,7 @@ bool CGUIWindowPictures::OnMessage(CGUIMessage& message) if (iAction == ACTION_DELETE_ITEM) { // is delete allowed? - if (g_guiSettings.GetBool("filelists.allowfiledeletion")) + if (CSettings::Get().GetBool("filelists.allowfiledeletion")) OnDeleteItem(iItem); else return false; @@ -176,7 +175,7 @@ void CGUIWindowPictures::UpdateButtons() CGUIMediaWindow::UpdateButtons(); // Update the shuffle button - if (g_guiSettings.GetBool("slideshow.shuffle")) + if (CSettings::Get().GetBool("slideshow.shuffle")) { CGUIMessage msg2(GUI_MSG_SELECTED, GetID(), CONTROL_SHUFFLE); g_windowManager.SendMessage(msg2); @@ -217,7 +216,7 @@ void CGUIWindowPictures::OnPrepareFileItems(CFileItemList& items) if (items[i]->GetLabel().Equals("folder.jpg")) items.Remove(i); - if (items.GetFolderCount()==items.Size() || !g_guiSettings.GetBool("pictures.usetags")) + if (items.GetFolderCount()==items.Size() || !CSettings::Get().GetBool("pictures.usetags")) return; // Start the music info loader thread @@ -270,7 +269,7 @@ bool CGUIWindowPictures::Update(const CStdString &strDirectory, bool updateFilte return false; m_vecItems->SetArt("thumb", ""); - if (g_guiSettings.GetBool("pictures.generatethumbs")) + if (CSettings::Get().GetBool("pictures.generatethumbs")) m_thumbLoader.Load(*m_vecItems); m_vecItems->SetArt("thumb", CPictureThumbLoader::GetCachedImage(*m_vecItems, "thumb")); @@ -345,7 +344,7 @@ bool CGUIWindowPictures::ShowPicture(int iItem, bool startSlideShow) CFileItemPtr pItem = m_vecItems->Get(i); if (!pItem->m_bIsFolder && !(URIUtils::IsRAR(pItem->GetPath()) || URIUtils::IsZIP(pItem->GetPath())) && (pItem->IsPicture() || ( - g_guiSettings.GetBool("pictures.showvideos") && + CSettings::Get().GetBool("pictures.showvideos") && pItem->IsVideo()))) { pSlideShow->Add(pItem.get()); @@ -407,7 +406,7 @@ void CGUIWindowPictures::OnSlideShowRecursive(const CStdString &strPicture) } m_slideShowStarted = true; pSlideShow->RunSlideShow(strPicture, true, - g_guiSettings.GetBool("slideshow.shuffle"),false, + CSettings::Get().GetBool("slideshow.shuffle"),false, m_guiState->GetSortMethod(), m_guiState->GetSortOrder(), strExtensions); @@ -481,7 +480,7 @@ void CGUIWindowPictures::GetContextButtons(int itemNumber, CContextButtons &butt if (!m_thumbLoader.IsLoading()) buttons.Add(CONTEXT_BUTTON_REFRESH_THUMBS, 13315); // Create Thumbnails - if (g_guiSettings.GetBool("filelists.allowfiledeletion") && !item->IsReadOnly()) + if (CSettings::Get().GetBool("filelists.allowfiledeletion") && !item->IsReadOnly()) { buttons.Add(CONTEXT_BUTTON_DELETE, 117); buttons.Add(CONTEXT_BUTTON_RENAME, 118); diff --git a/xbmc/pictures/GUIWindowSlideShow.cpp b/xbmc/pictures/GUIWindowSlideShow.cpp index 2c1cce6933cd8..150a0456a08ab 100644 --- a/xbmc/pictures/GUIWindowSlideShow.cpp +++ b/xbmc/pictures/GUIWindowSlideShow.cpp @@ -35,7 +35,7 @@ #include "guilib/GUIWindowManager.h" #include "settings/AdvancedSettings.h" #include "settings/DisplaySettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "FileItem.h" #include "guilib/Texture.h" #include "windowing/WindowingFactory.h" @@ -101,7 +101,7 @@ void CBackgroundPicLoader::Process() if (m_pCallback) { unsigned int start = XbmcThreads::SystemClockMillis(); - CBaseTexture* texture = CTexture::LoadFromFile(m_strFileName, m_maxWidth, m_maxHeight, g_guiSettings.GetBool("pictures.useexifrotation")); + CBaseTexture* texture = CTexture::LoadFromFile(m_strFileName, m_maxWidth, m_maxHeight, CSettings::Get().GetBool("pictures.useexifrotation")); totalTime += XbmcThreads::SystemClockMillis() - start; count++; // tell our parent @@ -838,7 +838,7 @@ bool CGUIWindowSlideShow::OnMessage(CGUIMessage& message) { case GUI_MSG_WINDOW_INIT: { - m_Resolution = (RESOLUTION) g_guiSettings.GetInt("pictures.displayresolution"); + m_Resolution = (RESOLUTION) CSettings::Get().GetInt("pictures.displayresolution"); //FIXME: Use GUI resolution for now if (0 /*m_Resolution != CDisplaySettings::Get().GetCurrentResolution() && m_Resolution != INVALID && m_Resolution!=AUTORES*/) @@ -1027,7 +1027,7 @@ void CGUIWindowSlideShow::OnLoadPic(int iPic, int iSlideNumber, CBaseTexture* pT else { if (m_bSlideShow) - m_Image[iPic].SetTexture(iSlideNumber, pTexture, g_guiSettings.GetBool("slideshow.displayeffects") ? CSlideShowPic::EFFECT_RANDOM : CSlideShowPic::EFFECT_NONE); + m_Image[iPic].SetTexture(iSlideNumber, pTexture, CSettings::Get().GetBool("slideshow.displayeffects") ? CSlideShowPic::EFFECT_RANDOM : CSlideShowPic::EFFECT_NONE); else m_Image[iPic].SetTexture(iSlideNumber, pTexture, CSlideShowPic::EFFECT_NO_TIMEOUT); m_Image[iPic].SetOriginalSize(pTexture->GetOriginalWidth(), pTexture->GetOriginalHeight(), bFullSize); @@ -1113,7 +1113,7 @@ void CGUIWindowSlideShow::RunSlideShow(const CStdString &strPath, bRandom = bNotRandom = false; // NotRandom overrides the window setting - if ((!bNotRandom && g_guiSettings.GetBool("slideshow.shuffle")) || bRandom) + if ((!bNotRandom && CSettings::Get().GetBool("slideshow.shuffle")) || bRandom) Shuffle(); if (!beginSlidePath.IsEmpty()) diff --git a/xbmc/pictures/Picture.cpp b/xbmc/pictures/Picture.cpp index 4fd93d0b4e8b6..27a70c5c97817 100644 --- a/xbmc/pictures/Picture.cpp +++ b/xbmc/pictures/Picture.cpp @@ -25,7 +25,7 @@ #include "Picture.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "FileItem.h" #include "filesystem/File.h" #include "utils/log.h" @@ -184,7 +184,7 @@ bool CPicture::CreateTiledThumb(const std::vector &files, const std int y = i / num_across; // load in the image unsigned int width = tile_width - 2*tile_gap, height = tile_height - 2*tile_gap; - CBaseTexture *texture = CTexture::LoadFromFile(files[i], width, height, g_guiSettings.GetBool("pictures.useexifrotation")); + CBaseTexture *texture = CTexture::LoadFromFile(files[i], width, height, CSettings::Get().GetBool("pictures.useexifrotation")); if (texture && texture->GetWidth() && texture->GetHeight()) { GetScale(texture->GetWidth(), texture->GetHeight(), width, height); diff --git a/xbmc/pictures/PictureInfoLoader.cpp b/xbmc/pictures/PictureInfoLoader.cpp index ab6ec96d2c199..00b30d3d9f498 100644 --- a/xbmc/pictures/PictureInfoLoader.cpp +++ b/xbmc/pictures/PictureInfoLoader.cpp @@ -20,7 +20,7 @@ #include "PictureInfoLoader.h" #include "PictureInfoTag.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "FileItem.h" CPictureInfoLoader::CPictureInfoLoader() @@ -42,7 +42,7 @@ void CPictureInfoLoader::OnLoaderStart() m_mapFileItems->SetFastLookup(true); m_tagReads = 0; - m_loadTags = g_guiSettings.GetBool("pictures.usetags"); + m_loadTags = CSettings::Get().GetBool("pictures.usetags"); if (m_pProgressCallback) m_pProgressCallback->SetProgressMax(m_pVecItems->GetFileCount()); diff --git a/xbmc/pictures/PictureThumbLoader.cpp b/xbmc/pictures/PictureThumbLoader.cpp index 61c624d3b4281..2eb57f6a07d67 100644 --- a/xbmc/pictures/PictureThumbLoader.cpp +++ b/xbmc/pictures/PictureThumbLoader.cpp @@ -27,9 +27,9 @@ #include "filesystem/MultiPathDirectory.h" #include "guilib/GUIWindowManager.h" #include "GUIUserMessages.h" -#include "settings/GUISettings.h" #include "utils/URIUtils.h" #include "settings/AdvancedSettings.h" +#include "settings/Settings.h" #include "video/VideoThumbLoader.h" using namespace XFILE; @@ -73,7 +73,7 @@ bool CPictureThumbLoader::LoadItem(CFileItem* pItem) { thumb = thumbURL; } - else if (g_guiSettings.GetBool("myvideos.extractthumb") && g_guiSettings.GetBool("myvideos.extractflags")) + else if (CSettings::Get().GetBool("myvideos.extractthumb") && CSettings::Get().GetBool("myvideos.extractflags")) { CFileItem item(*pItem); CThumbExtractor* extract = new CThumbExtractor(item, pItem->GetPath(), true, thumbURL); diff --git a/xbmc/pictures/SlideShowPicture.cpp b/xbmc/pictures/SlideShowPicture.cpp index 8c2b282ff6022..dcf7d813b64ea 100644 --- a/xbmc/pictures/SlideShowPicture.cpp +++ b/xbmc/pictures/SlideShowPicture.cpp @@ -25,7 +25,6 @@ #include "settings/AdvancedSettings.h" #include "settings/DisplaySettings.h" #include "settings/Settings.h" -#include "settings/GUISettings.h" #include "windowing/WindowingFactory.h" #include "utils/log.h" #include "threads/SingleLock.h" @@ -98,7 +97,7 @@ void CSlideShowPic::SetTexture(int iSlideNumber, CBaseTexture* pTexture, DISPLAY m_transistionStart.type = transEffect; m_transistionStart.start = 0; // the +1's make sure it actually occurs - float fadeTime = std::min(0.2f*g_guiSettings.GetInt("slideshow.staytime"), 3.0f); + float fadeTime = std::min(0.2f*CSettings::Get().GetInt("slideshow.staytime"), 3.0f); m_transistionStart.length = (int)(g_graphicsContext.GetFPS() * fadeTime); // transition time in frames m_transistionEnd.type = transEffect; m_transistionEnd.length = m_transistionStart.length; @@ -134,7 +133,7 @@ void CSlideShowPic::SetTexture(int iSlideNumber, CBaseTexture* pTexture, DISPLAY m_fPosX = m_fPosY = 0.0f; m_fPosZ = 1.0f; m_fVelocityX = m_fVelocityY = m_fVelocityZ = 0.0f; - int iFrames = max((int)(g_graphicsContext.GetFPS() * g_guiSettings.GetInt("slideshow.staytime")), 1); + int iFrames = max((int)(g_graphicsContext.GetFPS() * CSettings::Get().GetInt("slideshow.staytime")), 1); if (m_displayEffect == EFFECT_PANORAMA) { RESOLUTION iRes = g_graphicsContext.GetVideoResolution(); @@ -344,9 +343,9 @@ void CSlideShowPic::Process(unsigned int currentTime, CDirtyRegionList &dirtyreg else if (m_displayEffect == EFFECT_ZOOM) { m_fPosZ += m_fVelocityZ; -/* if (m_fPosZ > 1.0f + 0.01f*g_guiSettings.GetInt("Slideshow.ZoomAmount")) +/* if (m_fPosZ > 1.0f + 0.01f*CSettings::Get().GetInt("Slideshow.ZoomAmount")) { - m_fPosZ = 1.0f + 0.01f * g_guiSettings.GetInt("Slideshow.ZoomAmount"); + m_fPosZ = 1.0f + 0.01f * CSettings::Get().GetInt("Slideshow.ZoomAmount"); m_fVelocityZ = -m_fVelocityZ; } if (m_fPosZ < 1.0f) @@ -675,7 +674,7 @@ void CSlideShowPic::Rotate(float fRotateAngle, bool immediate /* = false */) m_transistionTemp.length = IMMEDIATE_TRANSISTION_TIME; m_fTransistionAngle = (float)fRotateAngle / (float)m_transistionTemp.length; // reset the timer - m_transistionEnd.start = m_iCounter + m_transistionStart.length + (int)(g_graphicsContext.GetFPS() * g_guiSettings.GetInt("slideshow.staytime")); + m_transistionEnd.start = m_iCounter + m_transistionStart.length + (int)(g_graphicsContext.GetFPS() * CSettings::Get().GetInt("slideshow.staytime")); } void CSlideShowPic::Zoom(float fZoom, bool immediate /* = false */) @@ -692,7 +691,7 @@ void CSlideShowPic::Zoom(float fZoom, bool immediate /* = false */) m_transistionTemp.length = IMMEDIATE_TRANSISTION_TIME; m_fTransistionZoom = (fZoom - m_fZoomAmount) / (float)m_transistionTemp.length; // reset the timer - m_transistionEnd.start = m_iCounter + m_transistionStart.length + (int)(g_graphicsContext.GetFPS() * g_guiSettings.GetInt("slideshow.staytime")); + m_transistionEnd.start = m_iCounter + m_transistionStart.length + (int)(g_graphicsContext.GetFPS() * CSettings::Get().GetInt("slideshow.staytime")); // turn off the render effects until we're back down to normal zoom m_bNoEffect = true; } @@ -702,7 +701,7 @@ void CSlideShowPic::Move(float fDeltaX, float fDeltaY) m_fZoomLeft += fDeltaX; m_fZoomTop += fDeltaY; // reset the timer - // m_transistionEnd.start = m_iCounter + m_transistionStart.length + (int)(g_graphicsContext.GetFPS() * g_guiSettings.GetInt("slideshow.staytime")); + // m_transistionEnd.start = m_iCounter + m_transistionStart.length + (int)(g_graphicsContext.GetFPS() * CSettings::Get().GetInt("slideshow.staytime")); } void CSlideShowPic::Render() diff --git a/xbmc/powermanagement/PowerManager.cpp b/xbmc/powermanagement/PowerManager.cpp index 0756b1e1b11eb..f67195911115d 100644 --- a/xbmc/powermanagement/PowerManager.cpp +++ b/xbmc/powermanagement/PowerManager.cpp @@ -23,7 +23,7 @@ #include "Application.h" #include "cores/AudioEngine/AEFactory.h" #include "input/KeyboardStat.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "windowing/WindowingFactory.h" #include "utils/log.h" #include "utils/Weather.h" @@ -95,7 +95,7 @@ void CPowerManager::Initialize() void CPowerManager::SetDefaults() { - int defaultShutdown = g_guiSettings.GetInt("powermanagement.shutdownstate"); + int defaultShutdown = CSettings::Get().GetInt("powermanagement.shutdownstate"); switch (defaultShutdown) { @@ -134,7 +134,7 @@ void CPowerManager::SetDefaults() break; } - g_guiSettings.SetInt("powermanagement.shutdownstate", defaultShutdown); + ((CSettingInt*)CSettings::Get().GetSetting("powermanagement.shutdownstate"))->SetDefault(defaultShutdown); } bool CPowerManager::Powerdown() @@ -285,3 +285,20 @@ void CPowerManager::OnLowBattery() CAnnouncementManager::Announce(System, "xbmc", "OnLowBattery"); } + +void CPowerManager::SettingOptionsShutdownStatesFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t) +{ + if (g_powerManager.CanPowerdown()) + list.push_back(make_pair(g_localizeStrings.Get(13005), POWERSTATE_SHUTDOWN)); + if (g_powerManager.CanHibernate()) + list.push_back(make_pair(g_localizeStrings.Get(13010), POWERSTATE_HIBERNATE)); + if (g_powerManager.CanSuspend()) + list.push_back(make_pair(g_localizeStrings.Get(13011), POWERSTATE_SUSPEND)); + if (!g_application.IsStandAlone()) + { + list.push_back(make_pair(g_localizeStrings.Get(13009), POWERSTATE_QUIT)); +#if !defined(TARGET_DARWIN_IOS) + list.push_back(make_pair(g_localizeStrings.Get(13014), POWERSTATE_MINIMIZE)); +#endif + } +} diff --git a/xbmc/powermanagement/PowerManager.h b/xbmc/powermanagement/PowerManager.h index 1a5c51fbc1645..a78bac8c5bd25 100644 --- a/xbmc/powermanagement/PowerManager.h +++ b/xbmc/powermanagement/PowerManager.h @@ -20,8 +20,26 @@ #ifndef _POWER_MANAGER_H_ #define _POWER_MANAGER_H_ + +#include +#include + #include "IPowerSyscall.h" +class CSetting; + +enum PowerState +{ + POWERSTATE_QUIT = 0, + POWERSTATE_SHUTDOWN, + POWERSTATE_HIBERNATE, + POWERSTATE_SUSPEND, + POWERSTATE_REBOOT, + POWERSTATE_MINIMIZE, + POWERSTATE_NONE, + POWERSTATE_ASK +}; + // For systems without PowerSyscalls we have a NullObject class CNullPowerSyscall : public IPowerSyscall { @@ -66,6 +84,9 @@ class CPowerManager : public IPowerEventsCallback int BatteryLevel(); void ProcessEvents(); + + static void SettingOptionsShutdownStatesFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t); + private: void OnSleep(); void OnWake(); diff --git a/xbmc/powermanagement/windows/Win32PowerSyscall.cpp b/xbmc/powermanagement/windows/Win32PowerSyscall.cpp index b02058371c4c1..d88cbf7110cf8 100644 --- a/xbmc/powermanagement/windows/Win32PowerSyscall.cpp +++ b/xbmc/powermanagement/windows/Win32PowerSyscall.cpp @@ -19,6 +19,7 @@ */ #include "Win32PowerSyscall.h" +#include "powermanagement/PowerManager.h" #ifdef _WIN32 #include "WIN32Util.h" diff --git a/xbmc/profiles/ProfilesManager.cpp b/xbmc/profiles/ProfilesManager.cpp index e05d8eddcfc4c..46ceca08a50cd 100644 --- a/xbmc/profiles/ProfilesManager.cpp +++ b/xbmc/profiles/ProfilesManager.cpp @@ -36,7 +36,6 @@ #include "guilib/LocalizeStrings.h" #include "input/ButtonTranslator.h" #include "input/MouseStat.h" -#include "settings/GUISettings.h" #include "settings/Settings.h" #if !defined(TARGET_WINDOWS) && defined(HAS_DVD_DRIVE) #include "storage/DetectDVDType.h" @@ -91,11 +90,11 @@ bool CProfilesManager::OnSettingsLoading() void CProfilesManager::OnSettingsLoaded() { // check them all - string strDir = g_guiSettings.GetString("system.playlistspath"); + string strDir = CSettings::Get().GetString("system.playlistspath"); if (strDir == "set default" || strDir.empty()) { strDir = "special://profile/playlists/"; - g_guiSettings.SetString("system.playlistspath", strDir.c_str()); + CSettings::Get().SetString("system.playlistspath", strDir.c_str()); } CDirectory::Create(strDir); @@ -244,9 +243,15 @@ bool CProfilesManager::LoadProfile(size_t index) m_currentProfile = index; - // load the new settings - if (!g_settings.Load()) + // first unload any old settings + CSettings::Get().Unload(); + // then load the new settings + if (!CSettings::Get().Load()) + { + CLog::Log(LOGFATAL, "CProfilesManager: unable to load settings for profile \"%s\"", m_profiles.at(index).getName().c_str()); return false; + } + CSettings::Get().SetLoaded(); CreateProfileFolders(); @@ -254,7 +259,7 @@ bool CProfilesManager::LoadProfile(size_t index) g_charsetConverter.reset(); // Load the langinfo to have user charset <-> utf-8 conversion - string strLanguage = g_guiSettings.GetString("locale.language"); + string strLanguage = CSettings::Get().GetString("locale.language"); strLanguage[0] = toupper(strLanguage[0]); string strLangInfoPath = StringUtils::Format("special://xbmc/language/%s/langinfo.xml", strLanguage.c_str()); @@ -266,7 +271,7 @@ bool CProfilesManager::LoadProfile(size_t index) CDatabaseManager::Get().Initialize(); - g_Mouse.SetEnabled(g_guiSettings.GetBool("input.enablemouse")); + g_Mouse.SetEnabled(CSettings::Get().GetBool("input.enablemouse")); g_infoManager.ResetCache(); g_infoManager.ResetLibraryBools(); @@ -278,7 +283,10 @@ bool CProfilesManager::LoadProfile(size_t index) { CXBMCTinyXML doc; if (doc.LoadFile(URIUtils::AddFileToFolder(GetUserDataFolder(), "guisettings.xml"))) - g_guiSettings.LoadMasterLock(doc.RootElement()); + { + CSettings::Get().LoadSetting(doc.RootElement(), "masterlock.maxretries"); + CSettings::Get().LoadSetting(doc.RootElement(), "masterlock.startuplock"); + } } CPasswordManager::GetInstance().Clear(); @@ -333,7 +341,7 @@ bool CProfilesManager::DeleteProfile(size_t index) if (index == m_currentProfile) { LoadProfile(0); - g_settings.Save(); + CSettings::Get().Save(); } CFileItemPtr item = CFileItemPtr(new CFileItem(URIUtils::AddFileToFolder(GetUserDataFolder(), strDirectory))); diff --git a/xbmc/profiles/dialogs/GUIDialogProfileSettings.cpp b/xbmc/profiles/dialogs/GUIDialogProfileSettings.cpp index 23e49516f4fe3..e6dd9f1e57c0a 100644 --- a/xbmc/profiles/dialogs/GUIDialogProfileSettings.cpp +++ b/xbmc/profiles/dialogs/GUIDialogProfileSettings.cpp @@ -34,7 +34,6 @@ #include "filesystem/File.h" #include "FileItem.h" #include "settings/Settings.h" -#include "settings/GUISettings.h" #include "guilib/LocalizeStrings.h" #include "TextureCache.h" @@ -340,12 +339,12 @@ bool CGUIDialogProfileSettings::ShowForProfile(unsigned int iProfile, bool first else { // create some new settings - CGUISettings localSettings; - localSettings.Initialize(); CStdString path = URIUtils::AddFileToFolder("special://masterprofile/", dialog->m_strDirectory); path = URIUtils::AddFileToFolder(path, "guisettings.xml"); + CSettings settings; - settings.SaveSettings(path, &localSettings); + settings.Initialize(); + settings.Save(path); } } diff --git a/xbmc/programs/GUIViewStatePrograms.cpp b/xbmc/programs/GUIViewStatePrograms.cpp index 9c4c8c84ca70d..ccdf7316192b1 100644 --- a/xbmc/programs/GUIViewStatePrograms.cpp +++ b/xbmc/programs/GUIViewStatePrograms.cpp @@ -21,24 +21,23 @@ #include "GUIViewStatePrograms.h" #include "FileItem.h" #include "view/ViewState.h" -#include "settings/GUISettings.h" #include "settings/MediaSourceSettings.h" #include "filesystem/Directory.h" #include "guilib/LocalizeStrings.h" #include "guilib/WindowIDs.h" +#include "settings/Settings.h" #include "view/ViewStateSettings.h" using namespace XFILE; -using namespace ADDON; CGUIViewStateWindowPrograms::CGUIViewStateWindowPrograms(const CFileItemList& items) : CGUIViewState(items) { - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) 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 - - CViewState *viewState = CViewStateSettings::Get().Get("programs"); + + const CViewState *viewState = CViewStateSettings::Get().Get("programs"); SetSortMethod(viewState->m_sortMethod); SetViewAsControl(viewState->m_viewMode); SetSortOrder(viewState->m_sortOrder); diff --git a/xbmc/pvr/PVRGUIInfo.cpp b/xbmc/pvr/PVRGUIInfo.cpp index 2064ba8741b08..787db29957cdf 100644 --- a/xbmc/pvr/PVRGUIInfo.cpp +++ b/xbmc/pvr/PVRGUIInfo.cpp @@ -32,7 +32,7 @@ #include "pvr/channels/PVRChannel.h" #include "epg/EpgInfoTag.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" using namespace PVR; using namespace EPG; @@ -238,7 +238,7 @@ void CPVRGUIInfo::UpdateQualityData(void) ClearQualityInfo(qualityInfo); PVR_CLIENT client; - if (g_guiSettings.GetBool("pvrplayback.signalquality") && + if (CSettings::Get().GetBool("pvrplayback.signalquality") && g_PVRClients->GetPlayingClient(client)) { client->SignalQuality(qualityInfo); diff --git a/xbmc/pvr/PVRManager.cpp b/xbmc/pvr/PVRManager.cpp index 805ff02bb57c5..2fb5de953ee0d 100644 --- a/xbmc/pvr/PVRManager.cpp +++ b/xbmc/pvr/PVRManager.cpp @@ -26,11 +26,11 @@ #include "dialogs/GUIDialogProgress.h" #include "dialogs/GUIDialogExtendedProgressBar.h" #include "dialogs/GUIDialogKaiToast.h" +#include "dialogs/GUIDialogYesNo.h" #include "guilib/GUIWindowManager.h" #include "guilib/LocalizeStrings.h" #include "music/tags/MusicInfoTag.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" #include "settings/MediaSettings.h" #include "settings/Settings.h" #include "threads/SingleLock.h" @@ -55,6 +55,7 @@ #include "interfaces/AnnouncementManager.h" #include "addons/AddonInstaller.h" #include "guilib/Key.h" +#include "dialogs/GUIDialogPVRChannelManager.h" using namespace std; using namespace MUSIC_INFO; @@ -91,6 +92,83 @@ CPVRManager &CPVRManager::Get(void) return pvrManagerInstance; } +void CPVRManager::OnSettingChanged(const CSetting *setting) +{ + if (setting == NULL) + return; + + const std::string &settingId = setting->GetId(); + if (settingId == "pvrmanager.enabled") + { + if (((CSettingBool*)setting)->GetValue()) + CApplicationMessenger::Get().ExecBuiltIn("XBMC.StartPVRManager", false); + else + CApplicationMessenger::Get().ExecBuiltIn("XBMC.StopPVRManager", false); + } + else if (settingId == "pvrparental.enabled") + { + if (((CSettingBool*)setting)->GetValue() && CSettings::Get().GetString("pvrparental.pin").empty()) + { + CStdString newPassword = ""; + // password set... save it + if (CGUIDialogNumeric::ShowAndVerifyNewPassword(newPassword)) + CSettings::Get().SetString("pvrparental.pin", newPassword); + // password not set... disable parental + else + ((CSettingBool*)setting)->SetValue(false); + } + } +} + +void CPVRManager::OnSettingAction(const CSetting *setting) +{ + if (setting == NULL) + return; + + const std::string &settingId = setting->GetId(); + if (settingId == "pvrmenu.searchicons") + { + if (IsStarted()) + SearchMissingChannelIcons(); + } + else if (settingId == "pvrmanager.resetdb") + { + if (CheckParentalPIN(g_localizeStrings.Get(19262).c_str()) && + CGUIDialogYesNo::ShowAndGetInput(19098, 19186, 750, 0)) + { + CDateTime::ResetTimezoneBias(); + ResetDatabase(false); + } + } + else if (settingId == "epg.resetepg") + { + if (CGUIDialogYesNo::ShowAndGetInput(19098, 19188, 750, 0)) + { + CDateTime::ResetTimezoneBias(); + ResetDatabase(true); + } + } + else if (settingId == "pvrmanager.channelscan") + { + if (IsStarted()) + StartChannelScan(); + } + else if (settingId == "pvrmanager.channelmanager") + { + if (IsStarted()) + { + CGUIDialogPVRChannelManager *dialog = (CGUIDialogPVRChannelManager *)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_CHANNEL_MANAGER); + if (dialog) + dialog->DoModal(); + } + } + else if (settingId == "pvrclient.menuhook") + { + if (IsStarted()) + Clients()->ProcessMenuHooks(-1, PVR_MENUHOOK_SETTING); + } +} + bool CPVRManager::IsPVRWindowActive(void) const { return g_windowManager.IsWindowActive(WINDOW_PVR) || @@ -115,7 +193,7 @@ bool CPVRManager::InstallAddonAllowed(const std::string& strAddonId) const void CPVRManager::MarkAsOutdated(const std::string& strAddonId, const std::string& strReferer) { - if (IsStarted() && g_guiSettings.GetBool("general.addonautoupdate")) + if (IsStarted() && CSettings::Get().GetBool("general.addonautoupdate")) { CSingleLock lock(m_critSection); m_outdatedAddons.insert(make_pair(strAddonId, strReferer)); @@ -261,7 +339,7 @@ void CPVRManager::Start(bool bAsync /* = false */, bool bOpenPVRWindow /* = fals Stop(); /* don't start if Settings->Video->TV->Enable isn't checked */ - if (!g_guiSettings.GetBool("pvrmanager.enabled")) + if (!CSettings::Get().GetBool("pvrmanager.enabled")) return; ResetProperties(); @@ -358,7 +436,7 @@ void CPVRManager::Process(void) while (GetState() == ManagerStateStarted && m_addons && m_addons->HasConnectedClients() && !bRestart) { /* continue last watched channel after first startup */ - if (m_bFirstStart && g_guiSettings.GetInt("pvrplayback.startlast") != START_LAST_CHANNEL_OFF) + if (m_bFirstStart && CSettings::Get().GetInt("pvrplayback.startlast") != START_LAST_CHANNEL_OFF) ContinueLastChannel(); /* execute the next pending jobs if there are any */ @@ -395,10 +473,10 @@ void CPVRManager::Process(void) bool CPVRManager::SetWakeupCommand(void) { - if (!g_guiSettings.GetBool("pvrpowermanagement.enabled")) + if (!CSettings::Get().GetBool("pvrpowermanagement.enabled")) return false; - const CStdString strWakeupCommand = g_guiSettings.GetString("pvrpowermanagement.setwakeupcmd", false); + const CStdString strWakeupCommand = CSettings::Get().GetString("pvrpowermanagement.setwakeupcmd"); if (!strWakeupCommand.IsEmpty() && m_timers) { time_t iWakeupTime; @@ -572,7 +650,7 @@ bool CPVRManager::ContinueLastChannel(void) if (channel && channel->HasPVRChannelInfoTag()) { CLog::Log(LOGNOTICE, "PVRManager - %s - continue playback on channel '%s'", __FUNCTION__, channel->GetPVRChannelInfoTag()->ChannelName().c_str()); - bReturn = StartPlayback(channel->GetPVRChannelInfoTag(), (g_guiSettings.GetInt("pvrplayback.startlast") == START_LAST_CHANNEL_MIN)); + bReturn = StartPlayback(channel->GetPVRChannelInfoTag(), (CSettings::Get().GetInt("pvrplayback.startlast") == START_LAST_CHANNEL_MIN)); } return bReturn; @@ -646,7 +724,7 @@ void CPVRManager::ResetDatabase(bool bResetEPGOnly /* = false */) CLog::Log(LOGNOTICE,"PVRManager - %s - %s database cleared", __FUNCTION__, bResetEPGOnly ? "EPG" : "PVR and EPG"); - if (g_guiSettings.GetBool("pvrmanager.enabled")) + if (CSettings::Get().GetBool("pvrmanager.enabled")) { CLog::Log(LOGNOTICE,"PVRManager - %s - restarting the PVRManager", __FUNCTION__); m_database->Open(); @@ -777,11 +855,11 @@ bool CPVRManager::IsParentalLocked(const CPVRChannel &channel) if (// different channel (!GetCurrentChannel(currentChannel) || channel != *currentChannel) && // parental control enabled - g_guiSettings.GetBool("pvrparental.enabled") && + CSettings::Get().GetBool("pvrparental.enabled") && // channel is locked channel.IsLocked()) { - float parentalDurationMs = g_guiSettings.GetInt("pvrparental.duration") * 1000.0f; + float parentalDurationMs = CSettings::Get().GetInt("pvrparental.duration") * 1000.0f; bReturn = m_parentalTimer && (!m_parentalTimer->IsRunning() || m_parentalTimer->GetElapsedMilliseconds() > parentalDurationMs); @@ -792,9 +870,9 @@ bool CPVRManager::IsParentalLocked(const CPVRChannel &channel) bool CPVRManager::CheckParentalPIN(const char *strTitle /* = NULL */) { - CStdString pinCode = g_guiSettings.GetString("pvrparental.pin"); + CStdString pinCode = CSettings::Get().GetString("pvrparental.pin"); - if (!g_guiSettings.GetBool("pvrparental.enabled") || pinCode.empty()) + if (!CSettings::Get().GetBool("pvrparental.enabled") || pinCode.empty()) return true; // Locked channel. Enter PIN: @@ -979,7 +1057,7 @@ bool CPVRManager::UpdateItem(CFileItem& item) { musictag->SetTitle(bHasTagNow ? epgTagNow.Title() : - g_guiSettings.GetBool("epg.hidenoinfoavailable") ? + CSettings::Get().GetBool("epg.hidenoinfoavailable") ? StringUtils::EmptyString : g_localizeStrings.Get(19055)); // no information available if (bHasTagNow) @@ -1000,7 +1078,7 @@ bool CPVRManager::UpdateItem(CFileItem& item) { videotag->m_strTitle = bHasTagNow ? epgTagNow.Title() : - g_guiSettings.GetBool("epg.hidenoinfoavailable") ? + CSettings::Get().GetBool("epg.hidenoinfoavailable") ? StringUtils::EmptyString : g_localizeStrings.Get(19055); // no information available if (bHasTagNow) @@ -1230,7 +1308,7 @@ bool CPVRManager::IsIdle(void) const else if (m_timers) // has active timers, etc.? { const CDateTime now = CDateTime::GetUTCDateTime(); - const CDateTimeSpan idle(0, 0, g_guiSettings.GetInt("pvrpowermanagement.backendidletime"), 0); + const CDateTimeSpan idle(0, 0, CSettings::Get().GetInt("pvrpowermanagement.backendidletime"), 0); const CDateTime next = m_timers->GetNextEventTime(); const CDateTimeSpan delta = next - now; @@ -1433,6 +1511,13 @@ bool CPVRManager::OnAction(const CAction &action) return false; } +void CPVRManager::SettingOptionsPvrStartLastChannelFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t) +{ + list.push_back(make_pair(g_localizeStrings.Get(106), PVR::START_LAST_CHANNEL_OFF)); + list.push_back(make_pair(g_localizeStrings.Get(19190), PVR::START_LAST_CHANNEL_MIN)); + list.push_back(make_pair(g_localizeStrings.Get(107), PVR::START_LAST_CHANNEL_ON)); +} + bool CPVRChannelSwitchJob::DoWork(void) { // announce OnStop and delete m_previous when done diff --git a/xbmc/pvr/PVRManager.h b/xbmc/pvr/PVRManager.h index 43cb555c44efb..8de823c19334e 100644 --- a/xbmc/pvr/PVRManager.h +++ b/xbmc/pvr/PVRManager.h @@ -19,15 +19,18 @@ * */ +#include + +#include "addons/include/xbmc_pvr_types.h" +#include "settings/ISettingCallback.h" +#include "threads/Event.h" #include "threads/Thread.h" #include "utils/JobManager.h" -#include "threads/Event.h" -#include "addons/include/xbmc_pvr_types.h" -#include class CGUIDialogProgressBarHandle; class CStopWatch; class CAction; +class CFileItemList; namespace EPG { @@ -65,6 +68,13 @@ namespace PVR PlaybackTypeRadio }; + enum ChannelStartLast + { + START_LAST_CHANNEL_OFF = 0, + START_LAST_CHANNEL_MIN, + START_LAST_CHANNEL_ON + }; + #define g_PVRManager CPVRManager::Get() #define g_PVRChannelGroups g_PVRManager.ChannelGroups() #define g_PVRTimers g_PVRManager.Timers() @@ -73,7 +83,7 @@ namespace PVR typedef boost::shared_ptr CPVRChannelGroupPtr; - class CPVRManager : private CThread + class CPVRManager : public ISettingCallback, private CThread { friend class CPVRClients; @@ -95,6 +105,9 @@ namespace PVR */ static CPVRManager &Get(void); + virtual void OnSettingChanged(const CSetting *setting); + virtual void OnSettingAction(const CSetting *setting); + /*! * @brief Get the channel groups container. * @return The groups container. @@ -495,6 +508,8 @@ namespace PVR */ bool OnAction(const CAction &action); + static void SettingOptionsPvrStartLastChannelFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t); + protected: /*! * @brief PVR update and control thread. diff --git a/xbmc/pvr/addons/PVRClient.cpp b/xbmc/pvr/addons/PVRClient.cpp index 408f163701f43..72aff209927f4 100644 --- a/xbmc/pvr/addons/PVRClient.cpp +++ b/xbmc/pvr/addons/PVRClient.cpp @@ -19,6 +19,7 @@ */ #include +#include "Application.h" #include "PVRClient.h" #include "pvr/PVRManager.h" #include "epg/Epg.h" @@ -27,8 +28,8 @@ #include "pvr/timers/PVRTimerInfoTag.h" #include "pvr/recordings/PVRRecordings.h" #include "settings/AdvancedSettings.h" +#include "settings/Settings.h" #include "utils/log.h" -#include "settings/GUISettings.h" using namespace std; using namespace ADDON; @@ -1431,7 +1432,7 @@ bool CPVRClient::CanSeekStream(void) const void CPVRClient::ResetQualityData(PVR_SIGNAL_STATUS &qualityInfo) { memset(&qualityInfo, 0, sizeof(qualityInfo)); - if (g_guiSettings.GetBool("pvrplayback.signalquality")) + if (CSettings::Get().GetBool("pvrplayback.signalquality")) { strncpy(qualityInfo.strAdapterName, g_localizeStrings.Get(13205).c_str(), PVR_ADDON_NAME_STRING_LENGTH - 1); strncpy(qualityInfo.strAdapterStatus, g_localizeStrings.Get(13205).c_str(), PVR_ADDON_NAME_STRING_LENGTH - 1); @@ -1466,7 +1467,7 @@ void CPVRClient::UpdateCharInfoSignalStatus(void) PVR_SIGNAL_STATUS qualityInfo; ResetQualityData(qualityInfo); - if (g_guiSettings.GetBool("pvrplayback.signalquality")) + if (CSettings::Get().GetBool("pvrplayback.signalquality")) SignalQuality(qualityInfo); CSingleLock lock(m_critSection); diff --git a/xbmc/pvr/addons/PVRClients.cpp b/xbmc/pvr/addons/PVRClients.cpp index f3fb8525fff65..16fad4457cba6 100644 --- a/xbmc/pvr/addons/PVRClients.cpp +++ b/xbmc/pvr/addons/PVRClients.cpp @@ -23,15 +23,14 @@ #include "Application.h" #include "ApplicationMessenger.h" #include "GUIUserMessages.h" -#include "settings/GUISettings.h" #include "dialogs/GUIDialogOK.h" #include "dialogs/GUIDialogSelect.h" #include "pvr/PVRManager.h" #include "pvr/PVRDatabase.h" #include "guilib/GUIWindowManager.h" #include "settings/DisplaySettings.h" -#include "settings/Settings.h" #include "settings/MediaSettings.h" +#include "settings/Settings.h" #include "pvr/channels/PVRChannelGroups.h" #include "pvr/channels/PVRChannelGroupInternal.h" #include "pvr/recordings/PVRRecordings.h" @@ -1155,7 +1154,7 @@ bool CPVRClients::UpdateAddons(void) // You need a tuner, backend software, and an add-on for the backend to be able to use PVR. // Please visit xbmc.org/pvr to learn more. m_bNoAddonWarningDisplayed = true; - g_guiSettings.SetBool("pvrmanager.enabled", false); + CSettings::Get().SetBool("pvrmanager.enabled", false); CGUIDialogOK::ShowAndGetInput(19271, 19272, 19273, 19274); CGUIMessage msg(GUI_MSG_UPDATE, WINDOW_SETTINGS_MYPVR, 0); g_windowManager.SendThreadMessage(msg, WINDOW_SETTINGS_MYPVR); diff --git a/xbmc/pvr/channels/PVRChannel.cpp b/xbmc/pvr/channels/PVRChannel.cpp index 1a627a5e77b09..adf5a89bfbb68 100644 --- a/xbmc/pvr/channels/PVRChannel.cpp +++ b/xbmc/pvr/channels/PVRChannel.cpp @@ -23,7 +23,6 @@ #include "utils/log.h" #include "Util.h" #include "filesystem/File.h" -#include "settings/GUISettings.h" #include "utils/StringUtils.h" #include "threads/SingleLock.h" diff --git a/xbmc/pvr/channels/PVRChannelGroup.cpp b/xbmc/pvr/channels/PVRChannelGroup.cpp index 170f6c3512967..c27f6244647ec 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.cpp +++ b/xbmc/pvr/channels/PVRChannelGroup.cpp @@ -23,8 +23,8 @@ * - use Observable here, so we can use event driven operations later */ -#include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" +#include "settings/Settings.h" #include "guilib/GUIWindowManager.h" #include "dialogs/GUIDialogYesNo.h" #include "dialogs/GUIDialogOK.h" @@ -116,8 +116,8 @@ bool CPVRChannelGroup::Load(void) /* make sure this container is empty before loading */ Unload(); - m_bUsingBackendChannelOrder = g_guiSettings.GetBool("pvrmanager.backendchannelorder"); - m_bUsingBackendChannelNumbers = g_guiSettings.GetBool("pvrmanager.usebackendchannelnumbers"); + m_bUsingBackendChannelOrder = CSettings::Get().GetBool("pvrmanager.backendchannelorder"); + m_bUsingBackendChannelNumbers = CSettings::Get().GetBool("pvrmanager.usebackendchannelnumbers"); int iChannelCount = m_iGroupId > 0 ? LoadFromDb() : 0; CLog::Log(LOGDEBUG, "PVRChannelGroup - %s - %d channels loaded from the database for group '%s'", @@ -137,7 +137,6 @@ bool CPVRChannelGroup::Load(void) SortAndRenumber(); - g_guiSettings.RegisterObserver(this); m_bLoaded = true; return true; @@ -146,14 +145,13 @@ bool CPVRChannelGroup::Load(void) void CPVRChannelGroup::Unload(void) { CSingleLock lock(m_critSection); - g_guiSettings.UnregisterObserver(this); m_members.clear(); } bool CPVRChannelGroup::Update(void) { if (GroupType() == PVR_GROUP_TYPE_USER_DEFINED || - !g_guiSettings.GetBool("pvrmanager.syncchannelgroups")) + !CSettings::Get().GetBool("pvrmanager.syncchannelgroups")) return true; CPVRChannelGroup PVRChannels_tmp(m_bRadio, m_iGroupId, m_strGroupName); @@ -240,7 +238,7 @@ bool CPVRChannelGroup::SetChannelIconPath(CPVRChannelPtr channel, const std::str void CPVRChannelGroup::SearchAndSetChannelIcons(bool bUpdateDb /* = false */) { - if (g_guiSettings.GetString("pvrmenu.iconpath").IsEmpty()) + if (CSettings::Get().GetString("pvrmenu.iconpath").empty()) return; CPVRDatabase *database = GetPVRDatabase(); @@ -257,7 +255,7 @@ void CPVRChannelGroup::SearchAndSetChannelIcons(bool bUpdateDb /* = false */) if (!groupMember.channel->IconPath().IsEmpty()) continue; - CStdString strBasePath = g_guiSettings.GetString("pvrmenu.iconpath"); + CStdString strBasePath = CSettings::Get().GetString("pvrmenu.iconpath"); CStdString strSanitizedChannelName = CUtil::MakeLegalFileName(groupMember.channel->ClientChannelName()); CStdString strIconPath = strBasePath + strSanitizedChannelName; @@ -884,7 +882,7 @@ bool CPVRChannelGroup::Renumber(void) { bool bReturn(false); unsigned int iChannelNumber(0); - bool bUseBackendChannelNumbers(g_guiSettings.GetBool("pvrmanager.usebackendchannelnumbers") && g_PVRClients->EnabledClientAmount() == 1); + bool bUseBackendChannelNumbers(CSettings::Get().GetBool("pvrmanager.usebackendchannelnumbers") && g_PVRClients->EnabledClientAmount() == 1); if (PreventSortAndRenumber()) return true; @@ -978,18 +976,24 @@ void CPVRChannelGroup::ResetChannelNumbers(void) m_members.at(iChannelPtr).channel->SetCachedChannelNumber(0); } -void CPVRChannelGroup::Notify(const Observable &obs, const ObservableMessage msg) +void CPVRChannelGroup::OnSettingChanged(const CSetting *setting) { + if (setting == NULL) + return; + /* TODO: while pvr manager is starting up do accept setting changes. */ if(!g_PVRManager.IsStarted()) { CLog::Log(LOGWARNING, "CPVRChannelGroup setting change ignored while PVRManager is starting\n"); + return; } - else if (msg == ObservableMessageGuiSettings) + + const std::string &settingId = setting->GetId(); + if (settingId == "pvrmanager.backendchannelorder" || settingId == "pvrmanager.usebackendchannelnumbers") { CSingleLock lock(m_critSection); - bool bUsingBackendChannelOrder = g_guiSettings.GetBool("pvrmanager.backendchannelorder"); - bool bUsingBackendChannelNumbers = g_guiSettings.GetBool("pvrmanager.usebackendchannelnumbers"); + bool bUsingBackendChannelOrder = CSettings::Get().GetBool("pvrmanager.backendchannelorder"); + bool bUsingBackendChannelNumbers = CSettings::Get().GetBool("pvrmanager.usebackendchannelnumbers"); bool bChannelNumbersChanged = m_bUsingBackendChannelNumbers != bUsingBackendChannelNumbers; bool bChannelOrderChanged = m_bUsingBackendChannelOrder != bUsingBackendChannelOrder; diff --git a/xbmc/pvr/channels/PVRChannelGroup.h b/xbmc/pvr/channels/PVRChannelGroup.h index 18d22e4b15471..b76e20ba301eb 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.h +++ b/xbmc/pvr/channels/PVRChannelGroup.h @@ -22,6 +22,7 @@ #include "FileItem.h" #include "PVRChannel.h" +#include "settings/ISettingCallback.h" #include "utils/JobManager.h" #include @@ -54,9 +55,9 @@ namespace PVR typedef boost::shared_ptr CPVRChannelGroupPtr; /** A group of channels */ - class CPVRChannelGroup : private Observer, - public Observable, - public IJobCallback + class CPVRChannelGroup : public Observable, + public IJobCallback, + public ISettingCallback { friend class CPVRChannelGroups; @@ -232,7 +233,7 @@ namespace PVR //@} - void Notify(const Observable &obs, const ObservableMessage msg); + virtual void OnSettingChanged(const CSetting *setting); /*! * @brief Get a channel given it's EPG ID. diff --git a/xbmc/pvr/channels/PVRChannelGroupInternal.cpp b/xbmc/pvr/channels/PVRChannelGroupInternal.cpp index 1073edf43c28d..b4556d68682c0 100644 --- a/xbmc/pvr/channels/PVRChannelGroupInternal.cpp +++ b/xbmc/pvr/channels/PVRChannelGroupInternal.cpp @@ -20,11 +20,10 @@ #include "PVRChannelGroupInternal.h" -#include "settings/GUISettings.h" -#include "settings/AdvancedSettings.h" #include "guilib/GUIWindowManager.h" #include "dialogs/GUIDialogYesNo.h" #include "dialogs/GUIDialogOK.h" +#include "settings/AdvancedSettings.h" #include "utils/log.h" #include "PVRChannelGroupsContainer.h" diff --git a/xbmc/pvr/channels/PVRChannelGroups.cpp b/xbmc/pvr/channels/PVRChannelGroups.cpp index c09aa1d7bdc8e..4a2971bbf37a6 100644 --- a/xbmc/pvr/channels/PVRChannelGroups.cpp +++ b/xbmc/pvr/channels/PVRChannelGroups.cpp @@ -21,7 +21,7 @@ #include "PVRChannelGroups.h" #include "FileItem.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "guilib/GUIWindowManager.h" #include "utils/log.h" #include "URL.h" @@ -52,7 +52,7 @@ void CPVRChannelGroups::Clear(void) bool CPVRChannelGroups::GetGroupsFromClients(void) { - if (! g_guiSettings.GetBool("pvrmanager.syncchannelgroups")) + if (! CSettings::Get().GetBool("pvrmanager.syncchannelgroups")) return true; return g_PVRClients->GetChannelGroups(this) == PVR_ERROR_NO_ERROR; @@ -160,7 +160,7 @@ void CPVRChannelGroups::RemoveFromAllGroups(const CPVRChannel &channel) bool CPVRChannelGroups::Update(bool bChannelsOnly /* = false */) { - bool bUpdateAllGroups = !bChannelsOnly && g_guiSettings.GetBool("pvrmanager.syncchannelgroups"); + bool bUpdateAllGroups = !bChannelsOnly && CSettings::Get().GetBool("pvrmanager.syncchannelgroups"); bool bReturn(true); // sync groups @@ -218,7 +218,7 @@ bool CPVRChannelGroups::LoadUserDefinedChannelGroups(void) if (!database) return false; - bool bSyncWithBackends = g_guiSettings.GetBool("pvrmanager.syncchannelgroups"); + bool bSyncWithBackends = CSettings::Get().GetBool("pvrmanager.syncchannelgroups"); CSingleLock lock(m_critSection); diff --git a/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp b/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp index 80e397d61c9f8..b32e781a0233d 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp @@ -38,7 +38,7 @@ #include "pvr/PVRManager.h" #include "pvr/channels/PVRChannelGroupsContainer.h" #include "pvr/addons/PVRClients.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "storage/MediaManager.h" #define BUTTON_OK 4 @@ -332,10 +332,10 @@ bool CGUIDialogPVRChannelManager::OnClickButtonChannelLogo(CGUIMessage &message) CStdString strThumb; VECSOURCES shares; - if (g_guiSettings.GetString("pvrmenu.iconpath") != "") + if (CSettings::Get().GetString("pvrmenu.iconpath") != "") { CMediaSource share1; - share1.strPath = g_guiSettings.GetString("pvrmenu.iconpath"); + share1.strPath = CSettings::Get().GetString("pvrmenu.iconpath"); share1.strName = g_localizeStrings.Get(19018); shares.push_back(share1); } diff --git a/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp b/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp index 040555a3b8a2c..0e5ba036808ca 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp @@ -29,7 +29,7 @@ #include "dialogs/GUIDialogOK.h" #include "GUIDialogPVRGuideInfo.h" #include "view/ViewState.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "GUIInfoManager.h" #include "cores/IPlayer.h" @@ -188,7 +188,7 @@ void CGUIDialogPVRChannelsOSD::Clear() void CGUIDialogPVRChannelsOSD::CloseOrSelect(unsigned int iItem) { - if (g_guiSettings.GetBool("pvrmenu.closechannelosdonswitch")) + if (CSettings::Get().GetBool("pvrmenu.closechannelosdonswitch")) Close(); else m_viewControl.SetSelectedItem(iItem); diff --git a/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp b/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp index 1f9fe1e6ebb22..69496b885858b 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp @@ -21,7 +21,6 @@ #include "GUIDialogPVRTimerSettings.h" #include "guilib/GUIKeyboardFactory.h" #include "dialogs/GUIDialogNumeric.h" -#include "settings/GUISettings.h" #include "guilib/LocalizeStrings.h" #include "pvr/PVRManager.h" diff --git a/xbmc/pvr/timers/PVRTimerInfoTag.cpp b/xbmc/pvr/timers/PVRTimerInfoTag.cpp index 1356b3996b5d0..ceb024775f7af 100644 --- a/xbmc/pvr/timers/PVRTimerInfoTag.cpp +++ b/xbmc/pvr/timers/PVRTimerInfoTag.cpp @@ -18,11 +18,11 @@ * */ -#include "settings/GUISettings.h" #include "dialogs/GUIDialogKaiToast.h" #include "dialogs/GUIDialogOK.h" #include "dialogs/GUIDialogYesNo.h" #include "settings/AdvancedSettings.h" +#include "settings/Settings.h" #include "utils/log.h" #include "utils/StringUtils.h" @@ -47,8 +47,8 @@ CPVRTimerInfoTag::CPVRTimerInfoTag(void) m_iClientId = g_PVRClients->GetFirstConnectedClientID(); m_iClientIndex = -1; m_iClientChannelUid = -1; - m_iPriority = g_guiSettings.GetInt("pvrrecord.defaultpriority"); - m_iLifetime = g_guiSettings.GetInt("pvrrecord.defaultlifetime"); + m_iPriority = CSettings::Get().GetInt("pvrrecord.defaultpriority"); + m_iLifetime = CSettings::Get().GetInt("pvrrecord.defaultlifetime"); m_bIsRepeating = false; m_iWeekdays = 0; m_strFileNameAndPath = StringUtils::EmptyString; @@ -56,8 +56,8 @@ CPVRTimerInfoTag::CPVRTimerInfoTag(void) m_bIsRadio = false; CEpgInfoTagPtr emptyTag; m_epgTag = emptyTag; - m_iMarginStart = g_guiSettings.GetInt("pvrrecord.marginstart"); - m_iMarginEnd = g_guiSettings.GetInt("pvrrecord.marginend"); + m_iMarginStart = CSettings::Get().GetInt("pvrrecord.marginstart"); + m_iMarginEnd = CSettings::Get().GetInt("pvrrecord.marginend"); m_iGenreType = 0; m_iGenreSubType = 0; m_StartTime = CDateTime::GetUTCDateTime(); @@ -542,7 +542,7 @@ void CPVRTimerInfoTag::GetNotificationText(CStdString &strText) const void CPVRTimerInfoTag::QueueNotification(void) const { - if (g_guiSettings.GetBool("pvrrecord.timernotifications")) + if (CSettings::Get().GetBool("pvrrecord.timernotifications")) { CStdString strMessage; GetNotificationText(strMessage); diff --git a/xbmc/pvr/timers/PVRTimers.cpp b/xbmc/pvr/timers/PVRTimers.cpp index 5335fa441a971..36187f3b8402b 100644 --- a/xbmc/pvr/timers/PVRTimers.cpp +++ b/xbmc/pvr/timers/PVRTimers.cpp @@ -19,7 +19,7 @@ */ #include "FileItem.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "dialogs/GUIDialogKaiToast.h" #include "dialogs/GUIDialogOK.h" #include "threads/SingleLock.h" @@ -252,7 +252,7 @@ bool CPVRTimers::UpdateEntries(const CPVRTimers &timers) NotifyObservers(bAddedOrDeleted ? ObservableMessageTimersReset : ObservableMessageTimers); - if (g_guiSettings.GetBool("pvrrecord.timernotifications")) + if (CSettings::Get().GetBool("pvrrecord.timernotifications")) { /* queue notifications */ for (unsigned int iNotificationPtr = 0; iNotificationPtr < timerNotifications.size(); iNotificationPtr++) @@ -497,7 +497,7 @@ bool CPVRTimers::InstantTimer(const CPVRChannel &channel) newTimer->SetStartFromUTC(startTime); newTimer->m_iMarginStart = 0; /* set the start margin to 0 for instant timers */ - int iDuration = g_guiSettings.GetInt("pvrrecord.instantrecordtime"); + int iDuration = CSettings::Get().GetInt("pvrrecord.instantrecordtime"); CDateTime endTime = CDateTime::GetUTCDateTime() + CDateTimeSpan(0, 0, iDuration ? iDuration : 120, 0); newTimer->SetEndFromUTC(endTime); @@ -657,10 +657,10 @@ void CPVRTimers::Notify(const Observable &obs, const ObservableMessage msg) CDateTime CPVRTimers::GetNextEventTime(void) const { - const bool dailywakup = g_guiSettings.GetBool("pvrpowermanagement.dailywakeup"); + const bool dailywakup = CSettings::Get().GetBool("pvrpowermanagement.dailywakeup"); const CDateTime now = CDateTime::GetUTCDateTime(); - const CDateTimeSpan prewakeup(0, 0, g_guiSettings.GetInt("pvrpowermanagement.prewakeup"), 0); - const CDateTimeSpan idle(0, 0, g_guiSettings.GetInt("pvrpowermanagement.backendidletime"), 0); + const CDateTimeSpan prewakeup(0, 0, CSettings::Get().GetInt("pvrpowermanagement.prewakeup"), 0); + const CDateTimeSpan idle(0, 0, CSettings::Get().GetInt("pvrpowermanagement.backendidletime"), 0); CDateTime wakeuptime; @@ -678,7 +678,7 @@ CDateTime CPVRTimers::GetNextEventTime(void) const if (dailywakup) { CDateTime dailywakeuptime; - dailywakeuptime.SetFromDBTime(g_guiSettings.GetString("pvrpowermanagement.dailywakeuptime", false)); + dailywakeuptime.SetFromDBTime(CSettings::Get().GetString("pvrpowermanagement.dailywakeuptime")); dailywakeuptime = dailywakeuptime.GetAsUTCDateTime(); dailywakeuptime.SetDateTime( diff --git a/xbmc/pvr/windows/GUIViewStatePVR.cpp b/xbmc/pvr/windows/GUIViewStatePVR.cpp index c065b5f236a9d..5390604e98480 100644 --- a/xbmc/pvr/windows/GUIViewStatePVR.cpp +++ b/xbmc/pvr/windows/GUIViewStatePVR.cpp @@ -22,7 +22,7 @@ #include "GUIWindowPVR.h" #include "GUIWindowPVRCommon.h" #include "guilib/GUIWindowManager.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" using namespace PVR; @@ -32,7 +32,7 @@ CGUIViewStatePVR::CGUIViewStatePVR(const CFileItemList& items) : PVRWindow ActiveView = GetActiveView(); if (ActiveView == PVR_WINDOW_RECORDINGS) { - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%L", "%I", "%L", "")); // FileName, Size | Foldername, e else AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%L", "%I", "%L", "")); // FileName, Size | Foldername, empty diff --git a/xbmc/pvr/windows/GUIWindowPVRChannels.cpp b/xbmc/pvr/windows/GUIWindowPVRChannels.cpp index 992747fb38a94..a574edc1551d6 100644 --- a/xbmc/pvr/windows/GUIWindowPVRChannels.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRChannels.cpp @@ -37,7 +37,7 @@ #include "pvr/addons/PVRClients.h" #include "pvr/timers/PVRTimers.h" #include "epg/EpgContainer.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "storage/MediaManager.h" #include "utils/log.h" #include "threads/SingleLock.h" @@ -446,7 +446,7 @@ bool CGUIWindowPVRChannels::OnContextButtonPlay(CFileItem *item, CONTEXT_BUTTON if (button == CONTEXT_BUTTON_PLAY_ITEM) { /* play channel */ - bReturn = PlayFile(item, g_guiSettings.GetBool("pvrplayback.playminimized")); + bReturn = PlayFile(item, CSettings::Get().GetBool("pvrplayback.playminimized")); } return bReturn; @@ -492,10 +492,10 @@ bool CGUIWindowPVRChannels::OnContextButtonSetThumb(CFileItem *item, CONTEXT_BUT CStdString strThumb; VECSOURCES shares; - if (g_guiSettings.GetString("pvrmenu.iconpath") != "") + if (CSettings::Get().GetString("pvrmenu.iconpath") != "") { CMediaSource share1; - share1.strPath = g_guiSettings.GetString("pvrmenu.iconpath"); + share1.strPath = CSettings::Get().GetString("pvrmenu.iconpath"); share1.strName = g_localizeStrings.Get(19018); shares.push_back(share1); } diff --git a/xbmc/pvr/windows/GUIWindowPVRCommon.cpp b/xbmc/pvr/windows/GUIWindowPVRCommon.cpp index 1cfbb1afaa4bc..92b22c76dbab3 100644 --- a/xbmc/pvr/windows/GUIWindowPVRCommon.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRCommon.cpp @@ -41,7 +41,6 @@ #include "pvr/windows/GUIWindowPVR.h" #include "pvr/windows/GUIWindowPVRSearch.h" #include "pvr/recordings/PVRRecordings.h" -#include "settings/GUISettings.h" #include "settings/MediaSettings.h" #include "settings/Settings.h" #include "utils/log.h" @@ -517,7 +516,7 @@ bool CGUIWindowPVRCommon::ActionPlayChannel(CFileItem *item) else { /* open channel */ - bReturn = PlayFile(item, g_guiSettings.GetBool("pvrplayback.playminimized")); + bReturn = PlayFile(item, CSettings::Get().GetBool("pvrplayback.playminimized")); } return bReturn; diff --git a/xbmc/pvr/windows/GUIWindowPVRGuide.cpp b/xbmc/pvr/windows/GUIWindowPVRGuide.cpp index 4dfd5fb832ad9..129ccc4244eb0 100644 --- a/xbmc/pvr/windows/GUIWindowPVRGuide.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRGuide.cpp @@ -29,7 +29,7 @@ #include "epg/EpgContainer.h" #include "pvr/windows/GUIWindowPVR.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "threads/SingleLock.h" #include "utils/log.h" #include "pvr/addons/PVRClients.h" @@ -41,7 +41,7 @@ using namespace EPG; CGUIWindowPVRGuide::CGUIWindowPVRGuide(CGUIWindowPVR *parent) : CGUIWindowPVRCommon(parent, PVR_WINDOW_EPG, CONTROL_BTNGUIDE, CONTROL_LIST_GUIDE_NOW_NEXT), Observer(), - m_iGuideView(g_guiSettings.GetInt("epg.defaultguideview")) + m_iGuideView(CSettings::Get().GetInt("epg.defaultguideview")) { m_cachedTimeline = new CFileItemList; m_cachedChannelGroup = CPVRChannelGroupPtr(new CPVRChannelGroup); @@ -487,3 +487,11 @@ void CGUIWindowPVRGuide::UpdateButtons(void) else if (m_iGuideView == GUIDE_VIEW_TIMELINE) m_parent->SetLabel(m_iControlButton, g_localizeStrings.Get(19222) + ": " + g_localizeStrings.Get(19032)); } + +void CGUIWindowPVRGuide::SettingOptionsEpgGuideViewFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t) +{ + list.push_back(make_pair(g_localizeStrings.Get(19029), PVR::GUIDE_VIEW_CHANNEL)); + list.push_back(make_pair(g_localizeStrings.Get(19030), PVR::GUIDE_VIEW_NOW)); + list.push_back(make_pair(g_localizeStrings.Get(19031), PVR::GUIDE_VIEW_NEXT)); + list.push_back(make_pair(g_localizeStrings.Get(19032), PVR::GUIDE_VIEW_TIMELINE)); +} diff --git a/xbmc/pvr/windows/GUIWindowPVRGuide.h b/xbmc/pvr/windows/GUIWindowPVRGuide.h index 12ba2c5a3480e..83c6990603930 100644 --- a/xbmc/pvr/windows/GUIWindowPVRGuide.h +++ b/xbmc/pvr/windows/GUIWindowPVRGuide.h @@ -26,8 +26,18 @@ #include "utils/Observer.h" #include "../channels/PVRChannelGroup.h" +class CSetting; + namespace PVR { + enum EpgGuideView + { + GUIDE_VIEW_CHANNEL = 0, + GUIDE_VIEW_NOW, + GUIDE_VIEW_NEXT, + GUIDE_VIEW_TIMELINE + }; + class CGUIWindowPVR; class CGUIWindowPVRGuide : public CGUIWindowPVRCommon, public Observer @@ -45,6 +55,8 @@ namespace PVR void SetInvalid(void) { UpdateData(); } void UnregisterObservers(void); void ResetObservers(void); + + static void SettingOptionsEpgGuideViewFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t); private: bool SelectPlayingFile(void); diff --git a/xbmc/rendering/dx/RenderSystemDX.cpp b/xbmc/rendering/dx/RenderSystemDX.cpp index b9b9b44e4a904..f057a2ce6dcf9 100644 --- a/xbmc/rendering/dx/RenderSystemDX.cpp +++ b/xbmc/rendering/dx/RenderSystemDX.cpp @@ -22,7 +22,6 @@ #ifdef HAS_DX #include "threads/SystemClock.h" -#include "settings/Settings.h" #include "RenderSystemDX.h" #include "utils/log.h" #include "utils/TimeUtils.h" @@ -30,8 +29,8 @@ #include "guilib/GUIWindowManager.h" #include "threads/SingleLock.h" #include "guilib/D3DResource.h" -#include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" +#include "settings/Settings.h" #include "utils/SystemInfo.h" #include "Application.h" #include "Util.h" diff --git a/xbmc/settings/AdvancedSettings.cpp b/xbmc/settings/AdvancedSettings.cpp index f4b02dbdc086e..354bd7548f801 100644 --- a/xbmc/settings/AdvancedSettings.cpp +++ b/xbmc/settings/AdvancedSettings.cpp @@ -28,7 +28,7 @@ #include "utils/LangCodeExpander.h" #include "LangInfo.h" #include "profiles/ProfilesManager.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/StringUtils.h" #include "utils/SystemInfo.h" #include "utils/URIUtils.h" @@ -41,6 +41,7 @@ using namespace XFILE; CAdvancedSettings::CAdvancedSettings() { m_initialized = false; + m_loaded = false; } void CAdvancedSettings::OnSettingsLoaded() @@ -54,7 +55,7 @@ void CAdvancedSettings::OnSettingsLoaded() CLog::Log(LOGNOTICE, "Default Audio Player: %s", m_audioDefaultPlayer.c_str()); // setup any logging... - if (g_guiSettings.GetBool("debug.showloginfo")) + if (CSettings::Get().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); @@ -67,6 +68,16 @@ void CAdvancedSettings::OnSettingsLoaded() CLog::SetLogLevel(m_logLevel); } +void CAdvancedSettings::OnSettingChanged(const CSetting *setting) +{ + if (setting == NULL) + return; + + const std::string &settingId = setting->GetId(); + if (settingId == "debug.showloginfo") + SetDebugMode(((CSettingBool*)setting)->GetValue()); +} + void CAdvancedSettings::Initialize() { m_audioHeadRoom = 0; @@ -378,6 +389,9 @@ bool CAdvancedSettings::Load() void CAdvancedSettings::ParseSettingsFile(const CStdString &file) { + if (m_loaded) + return; + CXBMCTinyXML advancedXML; if (!CFile::Exists(file)) { @@ -756,12 +770,12 @@ void CAdvancedSettings::ParseSettingsFile(const CStdString &file) { // read the loglevel setting, so set the setting advanced to hide it in GUI // as altering it will do nothing - we don't write to advancedsettings.xml XMLUtils::GetInt(pRootElement, "loglevel", m_logLevelHint, LOG_LEVEL_NONE, LOG_LEVEL_MAX); - CSettingBool *setting = (CSettingBool *)g_guiSettings.GetSetting("debug.showloginfo"); - if (setting) + CSettingBool *setting = (CSettingBool *)CSettings::Get().GetSetting("debug.showloginfo"); + if (setting != NULL) { const char* hide; if (!((hide = pElement->Attribute("hide")) && strnicmp("false", hide, 4) == 0)) - setting->SetAdvanced(); + setting->SetVisible(false); } g_advancedSettings.m_logLevel = std::max(g_advancedSettings.m_logLevel, g_advancedSettings.m_logLevelHint); CLog::SetLogLevel(g_advancedSettings.m_logLevel); @@ -1089,8 +1103,11 @@ void CAdvancedSettings::ParseSettingsFile(const CStdString &file) XMLUtils::GetInt(pElement, "nofliptimeout", m_guiDirtyRegionNoFlipTimeout); } - // load in the GUISettings overrides: - g_guiSettings.LoadXML(pRootElement, true); // true to hide the settings we read in + // must be done before calling CSettings::Load() to avoid an infinite loop + m_loaded = true; + + // load in the settings overrides + CSettings::Get().Load(pRootElement, true); // true to hide the settings we read in } void CAdvancedSettings::Clear() @@ -1112,6 +1129,8 @@ void CAdvancedSettings::Clear() m_logFolder.clear(); m_userAgent.clear(); + + m_loaded = false; } void CAdvancedSettings::GetCustomTVRegexps(TiXmlElement *pRootElement, SETTINGS_TVSHOWLIST& settings) diff --git a/xbmc/settings/AdvancedSettings.h b/xbmc/settings/AdvancedSettings.h index b6bf23a8610d3..dbc8d0c03b0eb 100644 --- a/xbmc/settings/AdvancedSettings.h +++ b/xbmc/settings/AdvancedSettings.h @@ -21,6 +21,7 @@ #include +#include "settings/ISettingCallback.h" #include "settings/ISettingsHandler.h" #include "utils/StdString.h" #include "utils/GlobalsHandling.h" @@ -82,7 +83,7 @@ struct RefreshVideoLatency typedef std::vector SETTINGS_TVSHOWLIST; -class CAdvancedSettings : public ISettingsHandler +class CAdvancedSettings : public ISettingCallback, public ISettingsHandler { public: CAdvancedSettings(); @@ -91,6 +92,8 @@ class CAdvancedSettings : public ISettingsHandler virtual void OnSettingsLoaded(); + virtual void OnSettingChanged(const CSetting *setting); + void Initialize(); bool Initialized() { return m_initialized; }; void AddSettingsFile(const CStdString &filename); @@ -363,6 +366,7 @@ class CAdvancedSettings : public ISettingsHandler float GetDisplayLatency(float refreshrate); bool m_initialized; + bool m_loaded; void SetDebugMode(bool debug); diff --git a/xbmc/settings/DisplaySettings.cpp b/xbmc/settings/DisplaySettings.cpp index 77846417650cb..40b12635a333b 100644 --- a/xbmc/settings/DisplaySettings.cpp +++ b/xbmc/settings/DisplaySettings.cpp @@ -22,12 +22,20 @@ #include #include "DisplaySettings.h" +#include "dialogs/GUIDialogYesNo.h" +#include "guilib/GraphicContext.h" #include "guilib/gui3d.h" -#include "settings/GUISettings.h" +#include "guilib/LocalizeStrings.h" +#include "settings/AdvancedSettings.h" +#include "settings/Settings.h" #include "threads/SingleLock.h" #include "utils/log.h" #include "utils/StringUtils.h" #include "utils/XMLUtils.h" +#include "windowing/WindowingFactory.h" + +// 0.1 second increments +#define MAX_REFRESH_CHANGE_DELAY 200 using namespace std; @@ -181,39 +189,103 @@ void CDisplaySettings::Clear() m_nonLinearStretched = false; } -void CDisplaySettings::SetCurrentResolution(RESOLUTION resolution, bool save /* = false */) +bool CDisplaySettings::OnSettingChanging(const CSetting *setting) { - if (save) + if (setting == NULL) + return false; + + const std::string &settingId = setting->GetId(); + if (settingId == "videoscreen.resolution" || + settingId == "videoscreen.screen" || + settingId == "videoscreen.screenmode") { - string mode; - if (resolution == RES_DESKTOP) - mode = "DESKTOP"; - else if (resolution == RES_WINDOW) - mode = "WINDOW"; - else if (resolution >= RES_CUSTOM && resolution < (RESOLUTION)m_resolutions.size()) + // check if this is the revert call for a failed OnSettingChanging + // in which case we don't want to ask the user again + if (m_ignoreSettingChanging.find(make_pair(settingId, true)) == m_ignoreSettingChanging.end()) { - const RESOLUTION_INFO &info = m_resolutions[resolution]; - mode = StringUtils::Format("%1i%05i%05i%09.5f%s", info.iScreen, - info.iScreenWidth, info.iScreenHeight, info.fRefreshRate, - (info.dwFlags & D3DPRESENTFLAG_INTERLACED) ? "i":"p"); + RESOLUTION newRes = RES_DESKTOP; + if (settingId == "videoscreen.resolution") + newRes = (RESOLUTION)((CSettingInt*)setting)->GetValue(); + else if (settingId == "videoscreen.screen") + newRes = GetResolutionForScreen(); + else if (settingId == "videoscreen.screenmode") + newRes = GetResolutionFromString(((CSettingString*)setting)->GetValue()); + + // We need to change and save videoscreen.screenmode which will + // trigger another call to this OnSettingChanging() which should not + // trigger a user-input dialog which is already triggered by the callback + // of the changed setting + bool save = settingId != "videoscreen.screenmode"; + if (save) + m_ignoreSettingChanging.insert(make_pair("videoscreen.screenmode", true)); + SetCurrentResolution(newRes, save); + g_graphicsContext.SetVideoResolution(newRes); + + // check if this setting is temporarily blocked from showing the dialog + if (m_ignoreSettingChanging.find(make_pair(settingId, false)) == m_ignoreSettingChanging.end()) + { + bool cancelled = false; + if (!CGUIDialogYesNo::ShowAndGetInput(13110, 13111, 20022, 20022, -1, -1, cancelled, 10000)) + { + // we need to ignore the next OnSettingChanging() call for + // the same setting which is executed to broadcast that + // changing the setting has failed + m_ignoreSettingChanging.insert(make_pair(settingId, false)); + return false; + } + } + else + m_ignoreSettingChanging.erase(make_pair(settingId, false)); + + if (settingId == "videoscreen.screen") + { + m_ignoreSettingChanging.insert(make_pair("videoscreen.resolution", true)); + if (CSettings::Get().GetSetting("videoscreen.screenmode")->IsVisible()) + m_ignoreSettingChanging.insert(make_pair("videoscreen.screenmode", true)); + } } else - { - CLog::Log(LOGWARNING, "CDisplaySettings: setting invalid resolution %i", resolution); - mode = "DESKTOP"; - } + m_ignoreSettingChanging.erase(make_pair(settingId, true)); + } + + return true; +} - g_guiSettings.SetString("videoscreen.screenmode", mode.c_str()); +bool CDisplaySettings::OnSettingUpdate(CSetting* &setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) +{ + if (setting == NULL) + return false; + + const std::string &settingId = setting->GetId(); + if (settingId == "videoscreen.screenmode") + { + CSettingString *screenmodeSetting = (CSettingString*)setting; + std::string screenmode = screenmodeSetting->GetValue(); + // in Eden there was no character ("i" or "p") indicating interlaced/progressive + // at the end so we just add a "p" and assume progressive + if (screenmode.size() == 20) + return screenmodeSetting->SetValue(screenmode + "p"); + } + + return false; +} + +void CDisplaySettings::SetCurrentResolution(RESOLUTION resolution, bool save /* = false */) +{ + if (save) + { + string mode = GetStringFromResolution(resolution); + CSettings::Get().SetString("videoscreen.screenmode", mode.c_str()); } m_currentResolution = resolution; - g_guiSettings.SetChanged(); + SetChanged(); } RESOLUTION CDisplaySettings::GetDisplayResolution() const { - return GetResolutionFromString(g_guiSettings.GetString("videoscreen.screenmode")); + return GetResolutionFromString(CSettings::Get().GetString("videoscreen.screenmode")); } const RESOLUTION_INFO& CDisplaySettings::GetResolutionInfo(size_t index) const @@ -340,7 +412,7 @@ void CDisplaySettings::UpdateCalibrations() } } -RESOLUTION CDisplaySettings::GetResolutionFromString(const std::string &strResolution) const +RESOLUTION CDisplaySettings::GetResolutionFromString(const std::string &strResolution) { if (strResolution == "DESKTOP") return RES_DESKTOP; @@ -360,9 +432,10 @@ RESOLUTION CDisplaySettings::GetResolutionFromString(const std::string &strResol // find the closest match to these in our res vector. If we have the screen, we score the res RESOLUTION bestRes = RES_DESKTOP; float bestScore = FLT_MAX; - for (ResolutionInfos::const_iterator resolution = m_resolutions.begin(); resolution != m_resolutions.end(); resolution++) + + for (size_t resolution = 0; resolution < CDisplaySettings::Get().ResolutionInfoSize(); resolution++) { - const RESOLUTION_INFO &info = *resolution; + const RESOLUTION_INFO &info = CDisplaySettings::Get().GetResolutionInfo(resolution); if (info.iScreen != screen) continue; float score = 10 * (square_error((float)info.iScreenWidth, (float)width) + @@ -372,7 +445,7 @@ RESOLUTION CDisplaySettings::GetResolutionFromString(const std::string &strResol if (score < bestScore) { bestScore = score; - bestRes = (RESOLUTION)(resolution - m_resolutions.begin()); + bestRes = (RESOLUTION)resolution; } } return bestRes; @@ -380,3 +453,131 @@ RESOLUTION CDisplaySettings::GetResolutionFromString(const std::string &strResol return RES_DESKTOP; } + +std::string CDisplaySettings::GetStringFromResolution(RESOLUTION resolution, float refreshrate /* = 0.0f */) +{ + if (resolution == RES_WINDOW) + return "WINDOW"; + + if (resolution >= RES_CUSTOM && resolution < (RESOLUTION)CDisplaySettings::Get().ResolutionInfoSize()) + { + const RESOLUTION_INFO &info = CDisplaySettings::Get().GetResolutionInfo(resolution); + return StringUtils::Format("%1i%05i%05i%09.5f%s", info.iScreen, + info.iScreenWidth, info.iScreenHeight, + refreshrate > 0.0f ? refreshrate : info.fRefreshRate, + (info.dwFlags & D3DPRESENTFLAG_INTERLACED) ? "i":"p"); + } + + return "DESKTOP"; +} + +RESOLUTION CDisplaySettings::GetResolutionForScreen() +{ + DisplayMode mode = CSettings::Get().GetInt("videoscreen.screen"); + if (mode == DM_WINDOWED) + return RES_WINDOW; + + for (int idx=0; idx < g_Windowing.GetNumScreens(); idx++) + { + if (CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP + idx).iScreen == mode) + return (RESOLUTION)(RES_DESKTOP + idx); + } + + return RES_DESKTOP; +} + +void CDisplaySettings::SettingOptionsRefreshChangeDelaysFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t) +{ + list.push_back(make_pair(g_localizeStrings.Get(13551), 0)); + + for (int i = 1; i <= MAX_REFRESH_CHANGE_DELAY; i++) + list.push_back(make_pair(StringUtils::Format(g_localizeStrings.Get(13553).c_str(), (double)i / 10.0), i)); +} + +void CDisplaySettings::SettingOptionsRefreshRatesFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t) +{ + // get the proper resolution + RESOLUTION res = GetResolutionForScreen(); + if (res < RES_WINDOW) + return; + + // only add "Windowed" if in windowed mode + if (res == RES_WINDOW) + { + current = "WINDOW"; + list.push_back(make_pair(g_localizeStrings.Get(242), current)); + return; + } + + // The only meaningful parts of res here are iScreen, iScreenWidth, iScreenHeight + vector refreshrates = g_Windowing.RefreshRates(CDisplaySettings::Get().GetResolutionInfo(res).iScreen, + CDisplaySettings::Get().GetResolutionInfo(res).iScreenWidth, + CDisplaySettings::Get().GetResolutionInfo(res).iScreenHeight, + CDisplaySettings::Get().GetResolutionInfo(res).dwFlags); + + bool match = false; + for (vector::const_iterator refreshrate = refreshrates.begin(); refreshrate != refreshrates.end(); refreshrate++) + { + std::string screenmode = GetStringFromResolution(res, refreshrate->RefreshRate); + if (!match && StringUtils::EqualsNoCase(((CSettingString*)setting)->GetValue(), screenmode)) + match = true; + list.push_back(make_pair(StringUtils::Format("%.02f", refreshrate->RefreshRate), screenmode)); + } + + if (!match) + current = GetStringFromResolution(res, g_Windowing.DefaultRefreshRate(CDisplaySettings::Get().GetResolutionInfo(res).iScreen, refreshrates).RefreshRate); +} + +void CDisplaySettings::SettingOptionsResolutionsFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t) +{ + RESOLUTION res = RES_INVALID; + DisplayMode screen = CSettings::Get().GetInt("videoscreen.screen"); + if (screen == DM_WINDOWED) + { + res = RES_WINDOW; + list.push_back(make_pair(g_localizeStrings.Get(242), RES_WINDOW)); + } + else + { + vector resolutions = g_Windowing.ScreenResolutions(screen); + for (vector::const_iterator resolution = resolutions.begin(); resolution != resolutions.end(); resolution++) + { + list.push_back(make_pair( + StringUtils::Format("%dx%d%s", resolution->width, resolution->height, (resolution->interlaced == D3DPRESENTFLAG_INTERLACED) ? "i" : "p"), + resolution->ResInfo_Index)); + + RESOLUTION_INFO res1 = CDisplaySettings::Get().GetCurrentResolutionInfo(); + RESOLUTION_INFO res2 = CDisplaySettings::Get().GetResolutionInfo(resolution->ResInfo_Index); + if (res1.iScreen == res2.iScreen && + res1.iScreenWidth == res2.iScreenWidth && + res1.iScreenHeight == res2.iScreenHeight && + (res1.dwFlags & D3DPRESENTFLAG_INTERLACED) == (res2.dwFlags & D3DPRESENTFLAG_INTERLACED)) + res = (RESOLUTION)resolution->ResInfo_Index; + } + } + + if (res != RES_INVALID) + current = res; +} + +void CDisplaySettings::SettingOptionsScreensFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t) +{ + if (g_advancedSettings.m_canWindowed) + list.push_back(make_pair(g_localizeStrings.Get(242), DM_WINDOWED)); + + for (int idx = 0; idx < g_Windowing.GetNumScreens(); idx++) + { + int screen = CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP + idx).iScreen; + list.push_back(make_pair(StringUtils::Format(g_localizeStrings.Get(241), screen + 1), screen)); + } +} + +void CDisplaySettings::SettingOptionsVerticalSyncsFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t) +{ +#if defined(_LINUX) && !defined(TARGET_DARWIN) + list.push_back(make_pair(g_localizeStrings.Get(13101), VSYNC_DRIVER)); +#endif + list.push_back(make_pair(g_localizeStrings.Get(13106), VSYNC_DISABLED)); + list.push_back(make_pair(g_localizeStrings.Get(13107), VSYNC_VIDEO)); + list.push_back(make_pair(g_localizeStrings.Get(13108), VSYNC_ALWAYS)); +} diff --git a/xbmc/settings/DisplaySettings.h b/xbmc/settings/DisplaySettings.h index aff6ddb968629..be4f159a00af4 100644 --- a/xbmc/settings/DisplaySettings.h +++ b/xbmc/settings/DisplaySettings.h @@ -19,15 +19,19 @@ * */ +#include #include #include "guilib/Resolution.h" +#include "settings/ISettingCallback.h" #include "settings/ISubSettings.h" #include "threads/CriticalSection.h" +#include "utils/Observer.h" class TiXmlNode; -class CDisplaySettings : public ISubSettings +class CDisplaySettings : public ISettingCallback, public ISubSettings, + public Observable { public: static CDisplaySettings& Get(); @@ -36,6 +40,9 @@ class CDisplaySettings : public ISubSettings virtual bool Save(TiXmlNode *settings) const; virtual void Clear(); + virtual bool OnSettingChanging(const CSetting *setting); + virtual bool OnSettingUpdate(CSetting* &setting, const char *oldSettingId, const TiXmlNode *oldSettingNode); + /*! \brief Returns the currently active resolution @@ -80,13 +87,21 @@ class CDisplaySettings : public ISubSettings bool IsNonLinearStretched() const { return m_nonLinearStretched; } void SetNonLinearStretched(bool nonLinearStretch) { m_nonLinearStretched = nonLinearStretch; } + static void SettingOptionsRefreshChangeDelaysFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t); + static void SettingOptionsRefreshRatesFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t); + static void SettingOptionsResolutionsFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t); + static void SettingOptionsScreensFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t); + static void SettingOptionsVerticalSyncsFiller(const CSetting *setting, std::vector< std::pair > &list, int ¤t); + protected: CDisplaySettings(); CDisplaySettings(const CDisplaySettings&); CDisplaySettings const& operator=(CDisplaySettings const&); virtual ~CDisplaySettings(); - RESOLUTION GetResolutionFromString(const std::string &strResolution) const; + static RESOLUTION GetResolutionFromString(const std::string &strResolution); + static std::string GetStringFromResolution(RESOLUTION resolution, float refreshrate = 0.0f); + static RESOLUTION GetResolutionForScreen(); private: // holds the real gui resolution @@ -100,5 +115,14 @@ class CDisplaySettings : public ISubSettings float m_pixelRatio; // current pixel ratio float m_verticalShift; // current vertical shift bool m_nonLinearStretched; // current non-linear stretch + + /*! + \brief A set of pairs consisting of a setting identifier + and a boolean value which should be ignored in specific + situations. If the boolean value is "true" the whole + OnSettingChanging() logic must be skipped once. If it + is "false" only showing the GUI dialog must be skipped. + */ + std::set< std::pair > m_ignoreSettingChanging; CCriticalSection m_critical; }; diff --git a/xbmc/settings/GUISettings.cpp b/xbmc/settings/GUISettings.cpp deleted file mode 100644 index 128a7115f3f4b..0000000000000 --- a/xbmc/settings/GUISettings.cpp +++ /dev/null @@ -1,1602 +0,0 @@ -/* - * Copyright (C) 2005-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 - * . - * - */ - -#include "network/Network.h" -#include "GUISettings.h" -#include -#include -#include "Settings.h" -#include "dialogs/GUIDialogFileBrowser.h" -#include "storage/MediaManager.h" -#ifdef _LINUX -#include "LinuxTimezone.h" -#endif -#include "Application.h" -#include "AdvancedSettings.h" -#include "guilib/LocalizeStrings.h" -#include "utils/CharsetConverter.h" -#include "settings/DisplaySettings.h" -#include "settings/VideoSettings.h" -#include "utils/StringUtils.h" -#include "utils/SystemInfo.h" -#include "utils/log.h" -#include "utils/XBMCTinyXML.h" -#include "windowing/WindowingFactory.h" -#include "powermanagement/PowerManager.h" -#include "cores/dvdplayer/DVDCodecs/Video/CrystalHD.h" -#include "cores/AudioEngine/AEFactory.h" -#include "cores/AudioEngine/AEAudioFormat.h" -#include "cores/paplayer/AudioDecoder.h" -#include "filesystem/CurlFile.h" -#include "guilib/GUIFont.h" // for FONT_STYLE_* definitions -#if defined(TARGET_DARWIN_OSX) - #include "cores/AudioEngine/Engines/CoreAudio/CoreAudioHardware.h" -#endif -#include "guilib/GUIFontManager.h" -#include "LangInfo.h" -#include "pvr/PVRManager.h" -#include "utils/XMLUtils.h" -#if defined(TARGET_DARWIN) - #include "osx/DarwinUtils.h" -#endif -#include "Util.h" - -using namespace std; -using namespace ADDON; -using namespace PVR; - -// String id's of the masks -#define MASK_DAYS 17999 -#define MASK_HOURS 17998 -#define MASK_MINS 14044 -#define MASK_SECS 14045 -#define MASK_MS 14046 -#define MASK_PERCENT 14047 -#define MASK_KBPS 14048 -#define MASK_MB 17997 -#define MASK_KB 14049 -#define MASK_DB 14050 - -#define MAX_RESOLUTIONS 128 - -#define TEXT_OFF 351 -#define TEXT_NONE 231 - -#ifdef _LINUX -#define DEFAULT_VISUALISATION "visualization.glspectrum" -#elif defined(_WIN32) -#ifdef HAS_DX -#define DEFAULT_VISUALISATION "visualization.milkdrop" -#else -#define DEFAULT_VISUALISATION "visualization.glspectrum" -#endif -#endif - -#define DEFAULT_WEB_INTERFACE "webinterface.default" - -#ifdef MID -#define DEFAULT_VSYNC VSYNC_DISABLED -#else // MID -#if defined(TARGET_DARWIN) || defined(_WIN32) || defined(TARGET_RASPBERRY_PI) -#define DEFAULT_VSYNC VSYNC_ALWAYS -#else -#define DEFAULT_VSYNC VSYNC_DRIVER -#endif -#endif // MID - -struct sortsettings -{ - bool operator()(const CSetting* pSetting1, const CSetting* pSetting2) - { - return pSetting1->GetOrder() < pSetting2->GetOrder(); - } -}; - -void CSettingBool::FromString(const CStdString &strValue) -{ - m_bData = (strValue == "true"); -} - -CStdString CSettingBool::ToString() const -{ - return m_bData ? "true" : "false"; -} - -CSettingSeparator::CSettingSeparator(int iOrder, const char *strSetting) - : CSetting(iOrder, strSetting, 0, SEPARATOR_CONTROL) -{ -} - -CSettingFloat::CSettingFloat(int iOrder, const char *strSetting, int iLabel, float fData, float fMin, float fStep, float fMax, int iControlType) - : CSetting(iOrder, strSetting, iLabel, iControlType) -{ - m_fData = fData; - m_fMin = fMin; - m_fStep = fStep; - m_fMax = fMax; -} - -void CSettingFloat::FromString(const CStdString &strValue) -{ - SetData((float)atof(strValue.c_str())); -} - -CStdString CSettingFloat::ToString() const -{ - CStdString strValue; - strValue.Format("%f", m_fData); - return strValue; -} - -CSettingInt::CSettingInt(int iOrder, const char *strSetting, int iLabel, int iData, int iMin, int iStep, int iMax, int iControlType, const char *strFormat) - : CSetting(iOrder, strSetting, iLabel, iControlType) -{ - m_iData = iData; - m_iMin = iMin; - m_iMax = iMax; - m_iStep = iStep; - m_iFormat = -1; - m_iLabelMin = -1; - if (strFormat) - m_strFormat = strFormat; - else - m_strFormat = "%i"; -} - -CSettingInt::CSettingInt(int iOrder, const char *strSetting, int iLabel, int iData, int iMin, int iStep, int iMax, int iControlType, int iFormat, int iLabelMin) - : CSetting(iOrder, strSetting, iLabel, iControlType) -{ - m_iData = iData; - m_iMin = iMin; - m_iMax = iMax; - m_iStep = iStep; - m_iLabelMin = iLabelMin; - m_iFormat = iFormat; - if (m_iFormat < 0) - m_strFormat = "%i"; -} - -CSettingInt::CSettingInt(int iOrder, const char *strSetting, int iLabel, - int iData, const map& entries, int iControlType) - : CSetting(iOrder, strSetting, iLabel, iControlType), - m_entries(entries) -{ - m_iData = iData; - m_iMin = -1; - m_iMax = -1; - m_iStep = 1; - m_iLabelMin = -1; -} - -void CSettingInt::FromString(const CStdString &strValue) -{ - int id = atoi(strValue.c_str()); - SetData(id); -} - -CStdString CSettingInt::ToString() const -{ - CStdString strValue; - strValue.Format("%i", m_iData); - return strValue; -} - -void CSettingHex::FromString(const CStdString &strValue) -{ - int iHexValue; - if (sscanf(strValue, "%x", (unsigned int *)&iHexValue)) - SetData(iHexValue); -} - -CStdString CSettingHex::ToString() const -{ - CStdString strValue; - strValue.Format("%x", m_iData); - return strValue; -} - -CSettingString::CSettingString(int iOrder, const char *strSetting, int iLabel, const char *strData, int iControlType, bool bAllowEmpty, int iHeadingString) - : CSetting(iOrder, strSetting, iLabel, iControlType) -{ - m_strData = strData; - m_bAllowEmpty = bAllowEmpty; - m_iHeadingString = iHeadingString; -} - -void CSettingString::FromString(const CStdString &strValue) -{ - m_strData = strValue; -} - -CStdString CSettingString::ToString() const -{ - return m_strData; -} - -CSettingPath::CSettingPath(int iOrder, const char *strSetting, int iLabel, const char *strData, int iControlType, bool bAllowEmpty, int iHeadingString) - : CSettingString(iOrder, strSetting, iLabel, strData, iControlType, bAllowEmpty, iHeadingString) -{ -} - -CSettingAddon::CSettingAddon(int iOrder, const char *strSetting, int iLabel, const char *strData, const TYPE type) - : CSettingString(iOrder, strSetting, iLabel, strData, BUTTON_CONTROL_STANDARD, false, -1) - , m_type(type) -{ -} - -CSettingsCategory* CSettingsGroup::AddCategory(const char *strCategory, int labelID) -{ - // Remove the category if it already exists - for (vecSettingsCategory::iterator it = m_vecCategories.begin(); it != m_vecCategories.end(); it++) - { - if ((*it)->m_strCategory.Equals(strCategory)) - { - delete (*it); - m_vecCategories.erase(it); - break; - } - } - CSettingsCategory *pCategory = new CSettingsCategory(strCategory, labelID); - if (pCategory) - m_vecCategories.push_back(pCategory); - return pCategory; -} - -void CSettingsGroup::GetCategories(vecSettingsCategory &vecCategories) -{ - vecCategories.clear(); - for (unsigned int i = 0; i < m_vecCategories.size(); i++) - { - vecSettings settings; - // check whether we actually have these settings available. - g_guiSettings.GetSettingsGroup(m_vecCategories[i], settings); - if (settings.size()) - vecCategories.push_back(m_vecCategories[i]); - } -} - -#define SETTINGS_PICTURES WINDOW_SETTINGS_MYPICTURES - WINDOW_SETTINGS_START -#define SETTINGS_PROGRAMS WINDOW_SETTINGS_MYPROGRAMS - WINDOW_SETTINGS_START -#define SETTINGS_WEATHER WINDOW_SETTINGS_MYWEATHER - WINDOW_SETTINGS_START -#define SETTINGS_MUSIC WINDOW_SETTINGS_MYMUSIC - WINDOW_SETTINGS_START -#define SETTINGS_SYSTEM WINDOW_SETTINGS_SYSTEM - WINDOW_SETTINGS_START -#define SETTINGS_VIDEOS WINDOW_SETTINGS_MYVIDEOS - WINDOW_SETTINGS_START -#define SETTINGS_SERVICE WINDOW_SETTINGS_SERVICE - WINDOW_SETTINGS_START -#define SETTINGS_APPEARANCE WINDOW_SETTINGS_APPEARANCE - WINDOW_SETTINGS_START -#define SETTINGS_PVR WINDOW_SETTINGS_MYPVR - WINDOW_SETTINGS_START - -// Settings are case sensitive -CGUISettings::CGUISettings(void) -{ -} - -void CGUISettings::Initialize() -{ - // Pictures settings - AddGroup(SETTINGS_PICTURES, 1); - CSettingsCategory* pic = AddCategory(SETTINGS_PICTURES, "pictures", 14081); - AddBool(pic, "pictures.usetags", 14082, true); - AddBool(pic,"pictures.generatethumbs",13360,true); - AddBool(pic, "pictures.useexifrotation", 20184, true); - AddBool(pic, "pictures.showvideos", 22022, true); - // FIXME: hide this setting until it is properly respected. In the meanwhile, default to AUTO. - AddInt(NULL, "pictures.displayresolution", 169, (int)RES_AUTORES, (int)RES_AUTORES, 1, (int)RES_AUTORES, SPIN_CONTROL_TEXT); - - CSettingsCategory* cat = AddCategory(SETTINGS_PICTURES, "slideshow", 108); - AddInt(cat, "slideshow.staytime", 12378, 5, 1, 1, 100, SPIN_CONTROL_INT_PLUS, MASK_SECS); - AddBool(cat, "slideshow.displayeffects", 12379, true); - AddBool(NULL, "slideshow.shuffle", 13319, false); - - // Programs settings -// AddGroup(1, 0); - - // My Weather settings - AddGroup(SETTINGS_WEATHER, 8); - CSettingsCategory* wea = AddCategory(SETTINGS_WEATHER, "weather", 16000); - AddInt(NULL, "weather.currentlocation", 0, 1, 1, 1, 3, SPIN_CONTROL_INT_PLUS); - AddDefaultAddon(wea, "weather.addon", 24029, "weather.wunderground", ADDON_SCRIPT_WEATHER); - AddString(wea, "weather.addonsettings", 21417, "", BUTTON_CONTROL_STANDARD, true); - - // My Music Settings - AddGroup(SETTINGS_MUSIC, 2); - CSettingsCategory* ml = AddCategory(SETTINGS_MUSIC,"musiclibrary",14022); - AddBool(NULL, "musiclibrary.enabled", 418, true); - AddBool(ml, "musiclibrary.showcompilationartists", 13414, true); - AddSeparator(ml,"musiclibrary.sep1"); - AddBool(ml,"musiclibrary.downloadinfo", 20192, false); - AddDefaultAddon(ml, "musiclibrary.albumsscraper", 20193, "metadata.album.universal", ADDON_SCRAPER_ALBUMS); - AddDefaultAddon(ml, "musiclibrary.artistsscraper", 20194, "metadata.artists.universal", ADDON_SCRAPER_ARTISTS); - AddBool(ml, "musiclibrary.updateonstartup", 22000, false); - AddBool(ml, "musiclibrary.backgroundupdate", 22001, false); - AddSeparator(ml,"musiclibrary.sep2"); - AddString(ml, "musiclibrary.cleanup", 334, "", BUTTON_CONTROL_STANDARD); - AddString(ml, "musiclibrary.export", 20196, "", BUTTON_CONTROL_STANDARD); - AddString(ml, "musiclibrary.import", 20197, "", BUTTON_CONTROL_STANDARD); - - CSettingsCategory* mp = AddCategory(SETTINGS_MUSIC, "musicplayer", 14086); - AddBool(mp, "musicplayer.autoplaynextitem", 489, true); - AddBool(mp, "musicplayer.queuebydefault", 14084, false); - AddSeparator(mp, "musicplayer.sep1"); - map gain; - gain.insert(make_pair(351,REPLAY_GAIN_NONE)); - gain.insert(make_pair(639,REPLAY_GAIN_TRACK)); - gain.insert(make_pair(640,REPLAY_GAIN_ALBUM)); - - AddInt(mp, "musicplayer.replaygaintype", 638, REPLAY_GAIN_ALBUM, gain, SPIN_CONTROL_TEXT); - AddInt(mp, "musicplayer.replaygainpreamp", 641, 89, 77, 1, 101, SPIN_CONTROL_INT_PLUS, MASK_DB); - AddInt(mp, "musicplayer.replaygainnogainpreamp", 642, 89, 77, 1, 101, SPIN_CONTROL_INT_PLUS, MASK_DB); - AddBool(mp, "musicplayer.replaygainavoidclipping", 643, false); - AddSeparator(mp, "musicplayer.sep2"); - AddInt(mp, "musicplayer.crossfade", 13314, 0, 0, 1, 15, SPIN_CONTROL_INT_PLUS, MASK_SECS, TEXT_OFF); - AddBool(mp, "musicplayer.crossfadealbumtracks", 13400, true); - AddSeparator(mp, "musicplayer.sep3"); - AddDefaultAddon(mp, "musicplayer.visualisation", 250, DEFAULT_VISUALISATION, ADDON_VIZ); - - CSettingsCategory* mf = AddCategory(SETTINGS_MUSIC, "musicfiles", 14081); - AddBool(mf, "musicfiles.usetags", 258, true); - AddString(mf, "musicfiles.trackformat", 13307, "[%N. ]%A - %T", EDIT_CONTROL_INPUT, false, 16016); - AddString(mf, "musicfiles.trackformatright", 13387, "%D", EDIT_CONTROL_INPUT, false, 16016); - // advanced per-view trackformats. - AddString(NULL, "musicfiles.nowplayingtrackformat", 13307, "", EDIT_CONTROL_INPUT, false, 16016); - AddString(NULL, "musicfiles.nowplayingtrackformatright", 13387, "", EDIT_CONTROL_INPUT, false, 16016); - AddString(NULL, "musicfiles.librarytrackformat", 13307, "", EDIT_CONTROL_INPUT, false, 16016); - AddString(NULL, "musicfiles.librarytrackformatright", 13387, "", EDIT_CONTROL_INPUT, false, 16016); - AddBool(mf, "musicfiles.findremotethumbs", 14059, true); - - CSettingsCategory* acd = AddCategory(SETTINGS_MUSIC, "audiocds", 620); - map autocd; - autocd.insert(make_pair(16018, AUTOCD_NONE)); - autocd.insert(make_pair(14098, AUTOCD_PLAY)); -#ifdef HAS_CDDA_RIPPER - autocd.insert(make_pair(14096, AUTOCD_RIP)); -#endif - AddInt(acd,"audiocds.autoaction",14097,AUTOCD_NONE, autocd, SPIN_CONTROL_TEXT); - AddBool(acd, "audiocds.usecddb", 227, true); - AddSeparator(acd, "audiocds.sep1"); - AddPath(acd,"audiocds.recordingpath",20000,"select writable folder",BUTTON_CONTROL_PATH_INPUT,false,657); - AddString(acd, "audiocds.trackpathformat", 13307, "%A - %B/[%N. ][%A - ]%T", EDIT_CONTROL_INPUT, false, 16016); - map encoders; -#ifdef HAVE_LIBMP3LAME - encoders.insert(make_pair(34000,CDDARIP_ENCODER_LAME)); -#endif -#ifdef HAVE_LIBVORBISENC - encoders.insert(make_pair(34001,CDDARIP_ENCODER_VORBIS)); -#endif - encoders.insert(make_pair(34002,CDDARIP_ENCODER_WAV)); - encoders.insert(make_pair(34005,CDDARIP_ENCODER_FLAC)); - AddInt(acd, "audiocds.encoder", 621, CDDARIP_ENCODER_FLAC, encoders, SPIN_CONTROL_TEXT); - - map qualities; - qualities.insert(make_pair(604,CDDARIP_QUALITY_CBR)); - qualities.insert(make_pair(601,CDDARIP_QUALITY_MEDIUM)); - qualities.insert(make_pair(602,CDDARIP_QUALITY_STANDARD)); - qualities.insert(make_pair(603,CDDARIP_QUALITY_EXTREME)); - AddInt(acd, "audiocds.quality", 622, CDDARIP_QUALITY_CBR, qualities, SPIN_CONTROL_TEXT); - AddInt(acd, "audiocds.bitrate", 623, 192, 128, 32, 320, SPIN_CONTROL_INT_PLUS, MASK_KBPS); - AddInt(acd, "audiocds.compressionlevel", 665, 5, 0, 1, 8, SPIN_CONTROL_INT_PLUS); - AddBool(acd, "audiocds.ejectonrip", 14099, true); - -#ifdef HAS_KARAOKE - CSettingsCategory* kar = AddCategory(SETTINGS_MUSIC, "karaoke", 13327); - AddBool(kar, "karaoke.enabled", 13323, false); - // auto-popup the song selector dialog when the karaoke song was just finished and playlist is empty. - AddBool(kar, "karaoke.autopopupselector", 22037, false); - AddSeparator(kar, "karaoke.sep1"); - AddString(kar, "karaoke.font", 22030, "arial.ttf", SPIN_CONTROL_TEXT); - AddInt(kar, "karaoke.fontheight", 22031, 36, 16, 2, 74, SPIN_CONTROL_TEXT); // use text as there is a disk based lookup needed - map colors; - for (int i = KARAOKE_COLOR_START; i < KARAOKE_COLOR_END; i++) - colors.insert(make_pair(22040 + i, i)); - AddInt(kar, "karaoke.fontcolors", 22032, KARAOKE_COLOR_START, colors, SPIN_CONTROL_TEXT); - AddString(kar, "karaoke.charset", 22033, "DEFAULT", SPIN_CONTROL_TEXT); - AddSeparator(kar,"karaoke.sep2"); - AddString(kar, "karaoke.export", 22038, "", BUTTON_CONTROL_STANDARD); - AddString(kar, "karaoke.importcsv", 22036, "", BUTTON_CONTROL_STANDARD); -#endif - - // System settings - AddGroup(SETTINGS_SYSTEM, 13000); - CSettingsCategory* vs = AddCategory(SETTINGS_SYSTEM, "videoscreen", 21373); - - // this setting would ideally not be saved, as its value is systematically derived from videoscreen.screenmode. - // contains a DISPLAYMODE -#if !defined(TARGET_DARWIN_IOS_ATV2) && !defined(TARGET_RASPBERRY_PI) - AddInt(vs, "videoscreen.screen", 240, 0, -1, 1, 32, SPIN_CONTROL_TEXT); -#endif - // this setting would ideally not be saved, as its value is systematically derived from videoscreen.screenmode. - // contains an index to the resolution info array in CDisplaySettings. the only meaningful fields are iScreen, iWidth, iHeight. -#if defined(TARGET_DARWIN) - #if !defined(TARGET_DARWIN_IOS_ATV2) - AddInt(vs, "videoscreen.resolution", 131, -1, 0, 1, INT_MAX, SPIN_CONTROL_TEXT); - #endif -#else - AddInt(vs, "videoscreen.resolution", 169, -1, 0, 1, INT_MAX, SPIN_CONTROL_TEXT); -#endif - AddString(g_application.IsStandAlone() ? vs : NULL, "videoscreen.screenmode", 243, "DESKTOP", SPIN_CONTROL_TEXT); - -#if defined(_WIN32) || defined(TARGET_DARWIN) - // We prefer a fake fullscreen mode (window covering the screen rather than dedicated fullscreen) - // as it works nicer with switching to other applications. However on some systems vsync is broken - // when we do this (eg non-Aero on ATI in particular) and on others (AppleTV) we can't get XBMC to - // the front - bool fakeFullScreen = true; - bool showSetting = true; - if (g_sysinfo.IsAeroDisabled()) - fakeFullScreen = false; - -#if defined(_WIN32) && defined(HAS_GL) - fakeFullScreen = true; - showSetting = false; -#endif - -#if defined(TARGET_DARWIN) - showSetting = false; -#endif - AddBool(showSetting ? vs : NULL, "videoscreen.fakefullscreen", 14083, fakeFullScreen); -#ifdef TARGET_DARWIN_IOS - AddBool(NULL, "videoscreen.blankdisplays", 13130, false); -#else - AddBool(vs, "videoscreen.blankdisplays", 13130, false); -#endif - - AddSeparator(vs, "videoscreen.sep1"); -#endif - - map vsync; -#if defined(_LINUX) && !defined(TARGET_DARWIN) - vsync.insert(make_pair(13101,VSYNC_DRIVER)); -#endif - vsync.insert(make_pair(13106,VSYNC_DISABLED)); - vsync.insert(make_pair(13107,VSYNC_VIDEO)); - vsync.insert(make_pair(13108,VSYNC_ALWAYS)); - AddInt(vs, "videoscreen.vsync", 13105, DEFAULT_VSYNC, vsync, SPIN_CONTROL_TEXT); - - AddString(vs, "videoscreen.guicalibration",214,"", BUTTON_CONTROL_STANDARD); -#if defined(HAS_GL) - // Todo: Implement test pattern for DX - AddString(vs, "videoscreen.testpattern",226,"", BUTTON_CONTROL_STANDARD); -#endif - -#if defined(HAS_GL) || defined(HAS_DX) - AddBool(vs , "videoscreen.limitedrange", 36042, false); -#else - AddBool(NULL, "videoscreen.limitedrange", 36042, false); -#endif - - CSettingsCategory* ao = AddCategory(SETTINGS_SYSTEM, "audiooutput", 772); - - map audiomode; - audiomode.insert(make_pair(338,AUDIO_ANALOG)); -#if !defined(TARGET_RASPBERRY_PI) - audiomode.insert(make_pair(339,AUDIO_IEC958)); -#endif - audiomode.insert(make_pair(420,AUDIO_HDMI )); -#if defined(TARGET_RASPBERRY_PI) - AddInt(ao, "audiooutput.mode", 337, AUDIO_HDMI, audiomode, SPIN_CONTROL_TEXT); -#else - AddInt(ao, "audiooutput.mode", 337, AUDIO_ANALOG, audiomode, SPIN_CONTROL_TEXT); -#endif - - map channelLayout; - for(int layout = AE_CH_LAYOUT_2_0; layout < AE_CH_LAYOUT_MAX; ++layout) - channelLayout.insert(make_pair(34100+layout, layout)); - AddInt(ao, "audiooutput.channels", 34100, AE_CH_LAYOUT_2_0, channelLayout, SPIN_CONTROL_TEXT); - AddBool(ao, "audiooutput.normalizelevels", 346, true); - AddBool(ao, "audiooutput.stereoupmix", 252, false); - -#if defined(TARGET_DARWIN_IOS) - CSettingsCategory* aocat = g_sysinfo.IsAppleTV2() ? ao : NULL; -#else - CSettingsCategory* aocat = ao; -#endif - - AddBool(aocat, "audiooutput.ac3passthrough" , 364, true); - AddBool(aocat, "audiooutput.dtspassthrough" , 254, true); - - -#if !defined(TARGET_DARWIN) && !defined(TARGET_RASPBERRY_PI) - AddBool(aocat, "audiooutput.passthroughaac" , 299, false); -#endif -#if !defined(TARGET_DARWIN_IOS) && !defined(TARGET_RASPBERRY_PI) - AddBool(aocat, "audiooutput.multichannellpcm" , 348, true ); -#endif -#if !defined(TARGET_DARWIN) && !defined(TARGET_RASPBERRY_PI) - AddBool(aocat, "audiooutput.truehdpassthrough", 349, true ); - AddBool(aocat, "audiooutput.dtshdpassthrough" , 347, true ); -#endif - -#if !defined(TARGET_RASPBERRY_PI) -#if defined(TARGET_DARWIN) - #if defined(TARGET_DARWIN_IOS) - CStdString defaultDeviceName = "Default"; - #else - CStdString defaultDeviceName; - CCoreAudioHardware::GetOutputDeviceName(defaultDeviceName); - #endif - AddString(ao, "audiooutput.audiodevice", 545, defaultDeviceName.c_str(), SPIN_CONTROL_TEXT); - AddString(NULL, "audiooutput.passthroughdevice", 546, defaultDeviceName.c_str(), SPIN_CONTROL_TEXT); -#else - AddSeparator(ao, "audiooutput.sep1"); - AddString (ao, "audiooutput.audiodevice" , 545, CStdString(CAEFactory::GetDefaultDevice(false)), SPIN_CONTROL_TEXT); - AddString (ao, "audiooutput.passthroughdevice", 546, CStdString(CAEFactory::GetDefaultDevice(true )), SPIN_CONTROL_TEXT); - AddSeparator(ao, "audiooutput.sep2"); -#endif -#endif - -#if !defined(TARGET_RASPBERRY_PI) - map guimode; - guimode.insert(make_pair(34121, AE_SOUND_IDLE )); - guimode.insert(make_pair(34122, AE_SOUND_ALWAYS)); - guimode.insert(make_pair(34123, AE_SOUND_OFF )); - AddInt(ao, "audiooutput.guisoundmode", 34120, AE_SOUND_IDLE, guimode, SPIN_CONTROL_TEXT); -#endif - - CSettingsCategory* in = AddCategory(SETTINGS_SYSTEM, "input", 14094); - AddString(in, "input.peripherals", 35000, "", BUTTON_CONTROL_STANDARD); -#if defined(TARGET_DARWIN) - map remotemode; - remotemode.insert(make_pair(13610,APPLE_REMOTE_DISABLED)); - remotemode.insert(make_pair(13611,APPLE_REMOTE_STANDARD)); - remotemode.insert(make_pair(13612,APPLE_REMOTE_UNIVERSAL)); - remotemode.insert(make_pair(13613,APPLE_REMOTE_MULTIREMOTE)); - AddInt(in, "input.appleremotemode", 13600, APPLE_REMOTE_STANDARD, remotemode, SPIN_CONTROL_TEXT); -#if defined(TARGET_DARWIN_OSX) - AddBool(in, "input.appleremotealwayson", 13602, false); -#else - AddBool(NULL, "input.appleremotealwayson", 13602, false); -#endif - AddInt(NULL, "input.appleremotesequencetime", 13603, 500, 50, 50, 1000, SPIN_CONTROL_INT_PLUS, MASK_MS, TEXT_OFF); - AddSeparator(in, "input.sep1"); -#endif - AddBool(in, "input.remoteaskeyboard", 21449, false); -#if defined(TARGET_DARWIN_IOS) - AddBool(NULL, "input.enablemouse", 21369, true); -#else - AddBool(in, "input.enablemouse", 21369, true); -#endif -#if defined(HAS_SDL_JOYSTICK) - AddBool(in, "input.enablejoystick", 35100, true); -#endif - - CSettingsCategory* net = AddCategory(SETTINGS_SYSTEM, "network", 798); - if (g_application.IsStandAlone()) - { -#if !defined(TARGET_DARWIN) - AddString(NULL, "network.interface",775,"", SPIN_CONTROL_TEXT); - - map networkAssignments; - networkAssignments.insert(make_pair(716, NETWORK_DHCP)); - networkAssignments.insert(make_pair(717, NETWORK_STATIC)); - networkAssignments.insert(make_pair(787, NETWORK_DISABLED)); - AddInt(NULL, "network.assignment", 715, NETWORK_DHCP, networkAssignments, SPIN_CONTROL_TEXT); - AddString(NULL, "network.ipaddress", 719, "0.0.0.0", EDIT_CONTROL_IP_INPUT); - AddString(NULL, "network.subnet", 720, "255.255.255.0", EDIT_CONTROL_IP_INPUT); - AddString(NULL, "network.gateway", 721, "0.0.0.0", EDIT_CONTROL_IP_INPUT); - AddString(NULL, "network.dns", 722, "0.0.0.0", EDIT_CONTROL_IP_INPUT); - AddString(NULL, "network.dnssuffix", 22002, "", EDIT_CONTROL_INPUT, true); - AddString(NULL, "network.essid", 776, "0.0.0.0", BUTTON_CONTROL_STANDARD); - - map networkEncapsulations; - networkEncapsulations.insert(make_pair(780, ENC_NONE)); - networkEncapsulations.insert(make_pair(781, ENC_WEP)); - networkEncapsulations.insert(make_pair(782, ENC_WPA)); - networkEncapsulations.insert(make_pair(783, ENC_WPA2)); - AddInt(NULL, "network.enc", 778, ENC_NONE, networkEncapsulations, SPIN_CONTROL_TEXT); - AddString(NULL, "network.key", 777, "0.0.0.0", EDIT_CONTROL_INPUT); -#ifndef _WIN32 - AddString(NULL, "network.save", 779, "", BUTTON_CONTROL_STANDARD); -#endif - AddSeparator(NULL, "network.sep1"); -#endif - } - AddBool(net, "network.usehttpproxy", 708, false); - map proxyTypes; - proxyTypes.insert(make_pair(1181, XFILE::CCurlFile::PROXY_HTTP)); - proxyTypes.insert(make_pair(1182, XFILE::CCurlFile::PROXY_SOCKS4)); - proxyTypes.insert(make_pair(1183, XFILE::CCurlFile::PROXY_SOCKS4A)); - proxyTypes.insert(make_pair(1184, XFILE::CCurlFile::PROXY_SOCKS5)); - proxyTypes.insert(make_pair(1185, XFILE::CCurlFile::PROXY_SOCKS5_REMOTE)); - AddInt(net, "network.httpproxytype", 1180, XFILE::CCurlFile::PROXY_HTTP, proxyTypes, SPIN_CONTROL_TEXT); - AddString(net, "network.httpproxyserver", 706, "", EDIT_CONTROL_INPUT); - AddString(net, "network.httpproxyport", 730, "8080", EDIT_CONTROL_NUMBER_INPUT, false, 707); - AddString(net, "network.httpproxyusername", 1048, "", EDIT_CONTROL_INPUT); - AddString(net, "network.httpproxypassword", 733, "", EDIT_CONTROL_HIDDEN_INPUT,true,733); - AddInt(net, "network.bandwidth", 14041, 0, 0, 512, 100*1024, SPIN_CONTROL_INT_PLUS, MASK_KBPS, TEXT_OFF); - - CSettingsCategory* pwm = AddCategory(SETTINGS_SYSTEM, "powermanagement", 14095); - // Note: Application.cpp might hide powersaving settings if not supported. - AddInt(pwm, "powermanagement.displaysoff", 1450, 0, 0, 5, 120, SPIN_CONTROL_INT_PLUS, MASK_MINS, TEXT_OFF); - AddInt(pwm, "powermanagement.shutdowntime", 357, 0, 0, 5, 120, SPIN_CONTROL_INT_PLUS, MASK_MINS, TEXT_OFF); - - map shutdown; - if (g_powerManager.CanPowerdown()) - shutdown.insert(make_pair(13005,POWERSTATE_SHUTDOWN)); - - if (g_powerManager.CanHibernate()) - shutdown.insert(make_pair(13010,POWERSTATE_HIBERNATE)); - - if (g_powerManager.CanSuspend()) - shutdown.insert(make_pair(13011,POWERSTATE_SUSPEND)); - - // In standalone mode we default to another. - if (g_application.IsStandAlone()) - AddInt(pwm, "powermanagement.shutdownstate", 13008, POWERSTATE_SHUTDOWN, shutdown, SPIN_CONTROL_TEXT); - else - { - shutdown.insert(make_pair(13009,POWERSTATE_QUIT)); -#if !defined(TARGET_DARWIN_IOS) - shutdown.insert(make_pair(13014,POWERSTATE_MINIMIZE)); -#endif - AddInt(pwm, "powermanagement.shutdownstate", 13008, POWERSTATE_QUIT, shutdown, SPIN_CONTROL_TEXT); - } - - CSettingsCategory* dbg = AddCategory(SETTINGS_SYSTEM, "debug", 14092); - AddBool(dbg, "debug.showloginfo", 20191, false); - AddPath(dbg, "debug.screenshotpath",20004,"select writable folder",BUTTON_CONTROL_PATH_INPUT,false,657); - - CSettingsCategory* mst = AddCategory(SETTINGS_SYSTEM, "masterlock", 12360); - AddString(mst, "masterlock.lockcode" , 20100, "-", BUTTON_CONTROL_STANDARD); - AddBool(mst, "masterlock.startuplock" , 20076,false); - // hidden masterlock settings - AddInt(NULL,"masterlock.maxretries", 12364, 3, 3, 1, 100, SPIN_CONTROL_TEXT); - - AddCategory(SETTINGS_SYSTEM, "cache", 439); - AddInt(NULL, "cache.harddisk", 14025, 256, 0, 256, 4096, SPIN_CONTROL_INT_PLUS, MASK_KB, TEXT_OFF); - AddSeparator(NULL, "cache.sep1"); - AddInt(NULL, "cachevideo.dvdrom", 14026, 2048, 0, 256, 16384, SPIN_CONTROL_INT_PLUS, MASK_KB, TEXT_OFF); - AddInt(NULL, "cachevideo.lan", 14027, 2048, 0, 256, 16384, SPIN_CONTROL_INT_PLUS, MASK_KB, TEXT_OFF); - AddInt(NULL, "cachevideo.internet", 14028, 4096, 0, 256, 16384, SPIN_CONTROL_INT_PLUS, MASK_KB, TEXT_OFF); - AddSeparator(NULL, "cache.sep2"); - AddInt(NULL, "cacheaudio.dvdrom", 14030, 256, 0, 256, 4096, SPIN_CONTROL_INT_PLUS, MASK_KB, TEXT_OFF); - AddInt(NULL, "cacheaudio.lan", 14031, 256, 0, 256, 4096, SPIN_CONTROL_INT_PLUS, MASK_KB, TEXT_OFF); - AddInt(NULL, "cacheaudio.internet", 14032, 256, 0, 256, 4096, SPIN_CONTROL_INT_PLUS, MASK_KB, TEXT_OFF); - AddSeparator(NULL, "cache.sep3"); - AddInt(NULL, "cachedvd.dvdrom", 14034, 2048, 0, 256, 16384, SPIN_CONTROL_INT_PLUS, MASK_KB, TEXT_OFF); - AddInt(NULL, "cachedvd.lan", 14035, 2048, 0, 256, 16384, SPIN_CONTROL_INT_PLUS, MASK_KB, TEXT_OFF); - AddSeparator(NULL, "cache.sep4"); - AddInt(NULL, "cacheunknown.internet", 14060, 4096, 0, 256, 16384, SPIN_CONTROL_INT_PLUS, MASK_KB, TEXT_OFF); - - // video settings - AddGroup(SETTINGS_VIDEOS, 3); - CSettingsCategory* vdl = AddCategory(SETTINGS_VIDEOS, "videolibrary", 14022); - AddBool(NULL, "videolibrary.enabled", 418, true); - AddBool(vdl, "videolibrary.showunwatchedplots", 20369, true); - AddBool(NULL, "videolibrary.seasonthumbs", 20382, true); - AddBool(vdl, "videolibrary.actorthumbs", 20402, true); - - map flattenTVShowOptions; - flattenTVShowOptions.insert(make_pair(20420, 0)); - flattenTVShowOptions.insert(make_pair(20421, 1)); - flattenTVShowOptions.insert(make_pair(20422, 2)); - AddInt(vdl, "videolibrary.flattentvshows", 20412, 1, flattenTVShowOptions, SPIN_CONTROL_TEXT); - - AddBool(vdl, "videolibrary.groupmoviesets", 20458, false); - AddBool(vdl, "videolibrary.updateonstartup", 22000, false); - AddBool(vdl, "videolibrary.backgroundupdate", 22001, false); - AddSeparator(vdl, "videolibrary.sep3"); - AddString(vdl, "videolibrary.cleanup", 334, "", BUTTON_CONTROL_STANDARD); - AddString(vdl, "videolibrary.export", 647, "", BUTTON_CONTROL_STANDARD); - AddString(vdl, "videolibrary.import", 648, "", BUTTON_CONTROL_STANDARD); - - CSettingsCategory* vp = AddCategory(SETTINGS_VIDEOS, "videoplayer", 14086); - - AddBool(vp, "videoplayer.autoplaynextitem", 13433, false); - AddSeparator(vp, "videoplayer.sep1"); - - map renderers; - renderers.insert(make_pair(13416, RENDER_METHOD_AUTO)); - -#ifdef HAS_DX - if (g_sysinfo.IsVistaOrHigher()) - renderers.insert(make_pair(16319, RENDER_METHOD_DXVA)); - renderers.insert(make_pair(13431, RENDER_METHOD_D3D_PS)); - renderers.insert(make_pair(13419, RENDER_METHOD_SOFTWARE)); -#endif - -#ifdef HAS_GL - renderers.insert(make_pair(13417, RENDER_METHOD_ARB)); - renderers.insert(make_pair(13418, RENDER_METHOD_GLSL)); - renderers.insert(make_pair(13419, RENDER_METHOD_SOFTWARE)); -#endif - AddInt(vp, "videoplayer.rendermethod", 13415, RENDER_METHOD_AUTO, renderers, SPIN_CONTROL_TEXT); - - AddInt(vp, "videoplayer.hqscalers", 13435, 0, 0, 10, 100, SPIN_CONTROL_INT); - -#ifdef HAVE_LIBVDPAU - AddBool(vp, "videoplayer.usevdpau", 13425, true); -#endif -#ifdef HAVE_LIBVA - AddBool(vp, "videoplayer.usevaapi", 13426, true); -#endif -#ifdef HAS_DX - AddBool(g_sysinfo.IsVistaOrHigher() ? vp: NULL, "videoplayer.usedxva2", 13427, g_sysinfo.IsVistaOrHigher() ? true : false); -#endif -#ifdef HAVE_LIBCRYSTALHD - AddBool(CCrystalHD::GetInstance()->DevicePresent() ? vp: NULL, "videoplayer.usechd", 13428, true); -#endif -#ifdef HAVE_LIBVDADECODER - AddBool(g_sysinfo.HasVDADecoder() ? vp: NULL, "videoplayer.usevda", 13429, true); -#endif -#ifdef HAVE_LIBOPENMAX - AddBool(vp, "videoplayer.useomx", 13430, true); -#endif -#ifdef HAVE_VIDEOTOOLBOXDECODER - AddBool(g_sysinfo.HasVideoToolBoxDecoder() ? vp: NULL, "videoplayer.usevideotoolbox", 13432, true); -#endif - -#ifdef HAS_GL - AddBool(NULL, "videoplayer.usepbo", 13424, true); -#endif - - // FIXME: hide this setting until it is properly respected. In the meanwhile, default to AUTO. - //AddInt(5, "videoplayer.displayresolution", 169, (int)RES_AUTORES, (int)RES_AUTORES, 1, (int)CUSTOM+MAX_RESOLUTIONS, SPIN_CONTROL_TEXT); - AddInt(NULL, "videoplayer.displayresolution", 169, (int)RES_AUTORES, (int)RES_AUTORES, 1, (int)RES_AUTORES, SPIN_CONTROL_TEXT); - - map adjustTypes; - adjustTypes.insert(make_pair(351, ADJUST_REFRESHRATE_OFF)); - adjustTypes.insert(make_pair(36035, ADJUST_REFRESHRATE_ALWAYS)); - adjustTypes.insert(make_pair(36036, ADJUST_REFRESHRATE_ON_STARTSTOP)); - -#if !defined(TARGET_DARWIN_IOS) - AddInt(vp, "videoplayer.adjustrefreshrate", 170, ADJUST_REFRESHRATE_OFF, adjustTypes, SPIN_CONTROL_TEXT); -// AddBool(vp, "videoplayer.adjustrefreshrate", 170, false); - AddInt(vp, "videoplayer.pauseafterrefreshchange", 13550, 0, 0, 1, MAXREFRESHCHANGEDELAY, SPIN_CONTROL_TEXT); -#else - AddInt(NULL, "videoplayer.adjustrefreshrate", 170, ADJUST_REFRESHRATE_OFF, adjustTypes, SPIN_CONTROL_TEXT); - //AddBool(NULL, "videoplayer.adjustrefreshrate", 170, false); - AddInt(NULL, "videoplayer.pauseafterrefreshchange", 13550, 0, 0, 1, MAXREFRESHCHANGEDELAY, SPIN_CONTROL_TEXT); -#endif - //sync settings not available on windows gl build -#if defined(_WIN32) && defined(HAS_GL) - #define SYNCSETTINGS 0 -#else - #define SYNCSETTINGS 1 -#endif - AddBool(SYNCSETTINGS ? vp : NULL, "videoplayer.usedisplayasclock", 13510, false); - - map syncTypes; - syncTypes.insert(make_pair(13501, SYNC_DISCON)); - syncTypes.insert(make_pair(13502, SYNC_SKIPDUP)); - syncTypes.insert(make_pair(13503, SYNC_RESAMPLE)); - AddInt(SYNCSETTINGS ? vp : NULL, "videoplayer.synctype", 13500, SYNC_RESAMPLE, syncTypes, SPIN_CONTROL_TEXT); - AddFloat(NULL, "videoplayer.maxspeedadjust", 13504, 5.0f, 0.0f, 0.1f, 10.0f); - - map resampleQualities; - resampleQualities.insert(make_pair(13506, RESAMPLE_LOW)); - resampleQualities.insert(make_pair(13507, RESAMPLE_MID)); - resampleQualities.insert(make_pair(13508, RESAMPLE_HIGH)); - resampleQualities.insert(make_pair(13509, RESAMPLE_REALLYHIGH)); - AddInt(NULL, "videoplayer.resamplequality", 13505, RESAMPLE_MID, resampleQualities, SPIN_CONTROL_TEXT); - AddInt(vp, "videoplayer.errorinaspect", 22021, 0, 0, 1, 20, SPIN_CONTROL_INT_PLUS, MASK_PERCENT, TEXT_NONE); - - map stretch; - 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 -#if defined(HAS_GL) || HAS_GLES == 2 // May need changing for GLES - AddSeparator(vp, "videoplayer.sep1.5"); -#ifdef HAVE_LIBVDPAU - AddBool(NULL, "videoplayer.vdpauUpscalingLevel", 13121, false); - AddBool(NULL, "videoplayer.vdpaustudiolevel", 0, false); //depreciated -#endif -#endif - AddSeparator(vp, "videoplayer.sep5"); - AddBool(vp, "videoplayer.teletextenabled", 23050, true); - AddBool(vp, "Videoplayer.teletextscale", 23055, true); - - CSettingsCategory* vid = AddCategory(SETTINGS_VIDEOS, "myvideos", 14081); - - map myVideosSelectActions; - myVideosSelectActions.insert(make_pair(22080, SELECT_ACTION_CHOOSE)); - myVideosSelectActions.insert(make_pair(208, SELECT_ACTION_PLAY_OR_RESUME)); - myVideosSelectActions.insert(make_pair(13404, SELECT_ACTION_RESUME)); - myVideosSelectActions.insert(make_pair(22081, SELECT_ACTION_INFO)); - - AddInt(vid, "myvideos.selectaction", 22079, SELECT_ACTION_PLAY_OR_RESUME, myVideosSelectActions, SPIN_CONTROL_TEXT); - AddBool(vid, "myvideos.extractflags",20433, true); - AddBool(vid, "myvideos.replacelabels", 20419, true); - AddBool(NULL, "myvideos.extractthumb",20433, true); - - AddSeparator(NULL, "myvideos.sep1"); - AddInt(NULL, "myvideos.startwindow", 0, WINDOW_VIDEO_FILES, WINDOW_VIDEO_FILES, 1, WINDOW_VIDEO_NAV, SPIN_CONTROL_INT); - AddBool(NULL, "myvideos.stackvideos", 0, false); - AddBool(NULL, "myvideos.flatten", 0, false); - - CSettingsCategory* sub = AddCategory(SETTINGS_VIDEOS, "subtitles", 287); - AddString(sub, "subtitles.font", 14089, "arial.ttf", SPIN_CONTROL_TEXT); - AddInt(sub, "subtitles.height", 289, 28, 16, 2, 74, SPIN_CONTROL_TEXT); // use text as there is a disk based lookup needed - - map fontStyles; - fontStyles.insert(make_pair(738, FONT_STYLE_NORMAL)); - fontStyles.insert(make_pair(739, FONT_STYLE_BOLD)); - fontStyles.insert(make_pair(740, FONT_STYLE_ITALICS)); - fontStyles.insert(make_pair(741, FONT_STYLE_BOLD | FONT_STYLE_ITALICS)); - - AddInt(sub, "subtitles.style", 736, FONT_STYLE_BOLD, fontStyles, SPIN_CONTROL_TEXT); - AddInt(sub, "subtitles.color", 737, SUBTITLE_COLOR_START + 1, SUBTITLE_COLOR_START, 1, SUBTITLE_COLOR_END, SPIN_CONTROL_TEXT); - AddString(sub, "subtitles.charset", 735, "DEFAULT", SPIN_CONTROL_TEXT); - AddBool(sub,"subtitles.overrideassfonts", 21368, false); - AddSeparator(sub, "subtitles.sep1"); - AddPath(sub, "subtitles.custompath", 21366, "", BUTTON_CONTROL_PATH_INPUT, false, 657); - - map subtitleAlignments; - subtitleAlignments.insert(make_pair(21461, SUBTITLE_ALIGN_MANUAL)); - subtitleAlignments.insert(make_pair(21462, SUBTITLE_ALIGN_BOTTOM_INSIDE)); - subtitleAlignments.insert(make_pair(21463, SUBTITLE_ALIGN_BOTTOM_OUTSIDE)); - subtitleAlignments.insert(make_pair(21464, SUBTITLE_ALIGN_TOP_INSIDE)); - subtitleAlignments.insert(make_pair(21465, SUBTITLE_ALIGN_TOP_OUTSIDE)); - AddInt(sub, "subtitles.align", 21460, SUBTITLE_ALIGN_MANUAL, subtitleAlignments, SPIN_CONTROL_TEXT); - - CSettingsCategory* dvd = AddCategory(SETTINGS_VIDEOS, "dvds", 14087); - AddBool(dvd, "dvds.autorun", 14088, false); - AddInt(dvd, "dvds.playerregion", 21372, 0, 0, 1, 8, SPIN_CONTROL_INT_PLUS, -1, TEXT_OFF); - AddBool(dvd, "dvds.automenu", 21882, false); - - AddDefaultAddon(NULL, "scrapers.moviesdefault", 21413, "metadata.themoviedb.org", ADDON_SCRAPER_MOVIES); - AddDefaultAddon(NULL, "scrapers.tvshowsdefault", 21414, "metadata.tvdb.com", ADDON_SCRAPER_TVSHOWS); - AddDefaultAddon(NULL, "scrapers.musicvideosdefault", 21415, "metadata.musicvideos.theaudiodb.com", ADDON_SCRAPER_MUSICVIDEOS); - - // service settings - AddGroup(SETTINGS_SERVICE, 14036); - - CSettingsCategory* srvGeneral = AddCategory(SETTINGS_SERVICE, "general", 16000); - AddString(srvGeneral,"services.devicename", 1271, "XBMC", EDIT_CONTROL_INPUT); - - CSettingsCategory* srvUpnp = AddCategory(SETTINGS_SERVICE, "upnp", 20187); - AddBool(srvUpnp, "services.upnpserver", 21360, false); - AddBool(srvUpnp, "services.upnpannounce", 20188, true); - AddBool(srvUpnp, "services.upnprenderer", 21881, false); - AddBool(srvUpnp, "services.upnpcontroller", 21361, false); - -#ifdef HAS_WEB_SERVER - CSettingsCategory* srvWeb = AddCategory(SETTINGS_SERVICE, "webserver", 33101); - AddBool(srvWeb, "services.webserver", 263, false); - AddString(srvWeb,"services.webserverport", 730, CUtil::CanBindPrivileged()?"80":"8080", EDIT_CONTROL_NUMBER_INPUT, false, 730); - AddString(srvWeb,"services.webserverusername",1048, "xbmc", EDIT_CONTROL_INPUT); - AddString(srvWeb,"services.webserverpassword",733, "", EDIT_CONTROL_HIDDEN_INPUT, true, 733); - AddDefaultAddon(srvWeb, "services.webskin",199, DEFAULT_WEB_INTERFACE, ADDON_WEB_INTERFACE); -#endif -#ifdef HAS_EVENT_SERVER - CSettingsCategory* srvEvent = AddCategory(SETTINGS_SERVICE, "remotecontrol", 790); - AddBool(srvEvent, "services.esenabled", 791, true); - AddString(NULL,"services.esport", 792, "9777", EDIT_CONTROL_NUMBER_INPUT, false, 792); - AddInt(NULL, "services.esportrange", 793, 10, 1, 1, 100, SPIN_CONTROL_INT); - AddInt(NULL, "services.esmaxclients", 797, 20, 1, 1, 100, SPIN_CONTROL_INT); - AddBool(srvEvent, "services.esallinterfaces", 794, false); - AddInt(NULL, "services.esinitialdelay", 795, 750, 5, 5, 10000, SPIN_CONTROL_INT); - AddInt(NULL, "services.escontinuousdelay", 796, 25, 5, 5, 10000, SPIN_CONTROL_INT); -#endif -#ifdef HAS_ZEROCONF - CSettingsCategory* srvZeroconf = AddCategory(SETTINGS_SERVICE, "zeroconf", 1259); -#ifdef TARGET_WINDOWS - AddBool(srvZeroconf, "services.zeroconf", 1260, false); -#else - AddBool(srvZeroconf, "services.zeroconf", 1260, true); -#endif -#endif - -#ifdef HAS_AIRPLAY - CSettingsCategory* srvAirplay = AddCategory(SETTINGS_SERVICE, "airplay", 1273); - AddBool(srvAirplay, "services.airplay", 1270, false); - AddBool(srvAirplay, "services.useairplaypassword", 1272, false); - AddString(srvAirplay, "services.airplaypassword", 733, "", EDIT_CONTROL_HIDDEN_INPUT, false, 733); -#endif - -#ifndef _WIN32 - CSettingsCategory* srvSmb = AddCategory(SETTINGS_SERVICE, "smb", 1200); - AddString(srvSmb, "smb.winsserver", 1207, "", EDIT_CONTROL_IP_INPUT); - AddString(srvSmb, "smb.workgroup", 1202, "WORKGROUP", EDIT_CONTROL_INPUT, false, 1202); -#endif - - // appearance settings - AddGroup(SETTINGS_APPEARANCE, 480); - CSettingsCategory* laf = AddCategory(SETTINGS_APPEARANCE,"lookandfeel", 166); - AddDefaultAddon(laf, "lookandfeel.skin",166,DEFAULT_SKIN, ADDON_SKIN); - AddString(laf, "lookandfeel.skinsettings", 21417, "", BUTTON_CONTROL_STANDARD); - AddString(laf, "lookandfeel.skintheme",15111,"SKINDEFAULT", SPIN_CONTROL_TEXT); - AddString(laf, "lookandfeel.skincolors",14078, "SKINDEFAULT", SPIN_CONTROL_TEXT); - AddString(laf, "lookandfeel.font",13303,"Default", SPIN_CONTROL_TEXT); - AddInt(laf, "lookandfeel.skinzoom",20109, 0, -20, 2, 20, SPIN_CONTROL_INT, MASK_PERCENT); - AddInt(laf, "lookandfeel.startupwindow",512,1, WINDOW_HOME, 1, WINDOW_PYTHON_END, SPIN_CONTROL_TEXT); - AddString(laf, "lookandfeel.soundskin",15108,"SKINDEFAULT", SPIN_CONTROL_TEXT); - AddSeparator(laf, "lookandfeel.sep2"); - AddBool(laf, "lookandfeel.enablerssfeeds",13305, true); - AddString(laf, "lookandfeel.rssedit", 21450, "", BUTTON_CONTROL_STANDARD); - - CSettingsCategory* loc = AddCategory(SETTINGS_APPEARANCE, "locale", 14090); - AddString(loc, "locale.language",248,"English", SPIN_CONTROL_TEXT); - AddString(loc, "locale.country", 20026, "USA (12h)", SPIN_CONTROL_TEXT); - AddString(loc, "locale.charset", 14091, "DEFAULT", SPIN_CONTROL_TEXT); // charset is set by the language file - - bool use_timezone = false; - -#if defined(_LINUX) -#if defined(TARGET_DARWIN) - if (g_sysinfo.IsAppleTV2() && GetIOSVersion() < 4.3) -#endif -#if !defined(TARGET_ANDROID) - use_timezone = true; -#endif - - if (use_timezone) - { - AddSeparator(loc, "locale.sep1"); - AddString(loc, "locale.timezonecountry", 14079, g_timezone.GetCountryByTimezone(g_timezone.GetOSConfiguredTimezone()), SPIN_CONTROL_TEXT); - AddString(loc, "locale.timezone", 14080, g_timezone.GetOSConfiguredTimezone(), SPIN_CONTROL_TEXT); - } -#endif - AddSeparator(loc, "locale.sep3"); - AddString(loc, "locale.audiolanguage", 285, "original", SPIN_CONTROL_TEXT); - AddString(loc, "locale.subtitlelanguage", 286, "original", SPIN_CONTROL_TEXT); - - CSettingsCategory* fl = AddCategory(SETTINGS_APPEARANCE, "filelists", 14081); - AddBool(fl, "filelists.showparentdiritems", 13306, true); - AddBool(fl, "filelists.showextensions", 497, true); - AddBool(fl, "filelists.ignorethewhensorting", 13399, true); - AddBool(fl, "filelists.allowfiledeletion", 14071, false); - AddBool(fl, "filelists.showaddsourcebuttons", 21382, true); - AddBool(fl, "filelists.showhidden", 21330, false); - - CSettingsCategory* ss = AddCategory(SETTINGS_APPEARANCE, "screensaver", 360); - AddDefaultAddon(ss, "screensaver.mode", 356, "screensaver.xbmc.builtin.dim", ADDON_SCREENSAVER); - AddString(ss, "screensaver.settings", 21417, "", BUTTON_CONTROL_STANDARD); - AddString(ss, "screensaver.preview", 1000, "", BUTTON_CONTROL_STANDARD); - AddInt(ss, "screensaver.time", 355, 3, 1, 1, 60, SPIN_CONTROL_INT_PLUS, MASK_MINS); - AddSeparator(ss, "screensaver.sep1"); - AddBool(ss, "screensaver.usemusicvisinstead", 13392, true); - AddBool(ss, "screensaver.usedimonpause", 22014, true); - - AddCategory(SETTINGS_APPEARANCE, "window", 0); - AddInt(NULL, "window.width", 0, 720, 10, 1, INT_MAX, SPIN_CONTROL_INT); - AddInt(NULL, "window.height", 0, 480, 10, 1, INT_MAX, SPIN_CONTROL_INT); - - AddPath(NULL,"system.playlistspath",20006,"set default",BUTTON_CONTROL_PATH_INPUT,false); - - AddInt(NULL, "mymusic.startwindow", 0, WINDOW_MUSIC_FILES, WINDOW_MUSIC_FILES, 1, WINDOW_MUSIC_NAV, SPIN_CONTROL_INT); - AddBool(NULL, "mymusic.songthumbinvis", 0, false); - AddString(NULL, "mymusic.defaultlibview", 0, "", BUTTON_CONTROL_STANDARD); - - AddBool(NULL, "general.addonautoupdate", 0, true); - AddBool(NULL, "general.addonnotifications", 0, true); - AddBool(NULL, "general.addonforeignfilter", 0, false); - - // tv settings (access over TV menu from home window) - AddGroup(SETTINGS_PVR, 19180); - CSettingsCategory* pvr = AddCategory(SETTINGS_PVR, "pvrmanager", 128); - AddBool(pvr, "pvrmanager.enabled", 449, false); - AddSeparator(pvr, "pvrmanager.sep1"); - AddBool(pvr, "pvrmanager.syncchannelgroups", 19221, true); - AddBool(pvr, "pvrmanager.backendchannelorder", 19231, true); - AddBool(pvr, "pvrmanager.usebackendchannelnumbers", 19234, false); - AddSeparator(pvr, "pvrmanager.sep2"); - AddString(pvr, "pvrmanager.channelmanager", 19199, "", BUTTON_CONTROL_STANDARD); - AddString(pvr, "pvrmanager.channelscan", 19117, "", BUTTON_CONTROL_STANDARD); - AddString(pvr, "pvrmanager.resetdb", 19185, "", BUTTON_CONTROL_STANDARD); - AddSeparator(pvr, "pvrmanager.sep3"); - AddBool(pvr, "pvrmanager.hideconnectionlostwarning", 19269, false); - - CSettingsCategory* pvrm = AddCategory(SETTINGS_PVR, "pvrmenu", 19181); - AddBool(pvrm, "pvrmenu.infoswitch", 19178, true); - AddBool(pvrm, "pvrmenu.infotimeout", 19179, true); - AddBool(pvrm, "pvrmenu.closechannelosdonswitch", 19229, false); - AddInt(pvrm, "pvrmenu.infotime", 19184, 5, 1, 1, 10, SPIN_CONTROL_INT_PLUS, MASK_SECS); - AddSeparator(pvrm, "pvrmenu.sep1"); - AddString(pvrm, "pvrmenu.iconpath", 19018, "", BUTTON_CONTROL_PATH_INPUT, false, 657); - AddString(pvrm, "pvrmenu.searchicons", 19167, "", BUTTON_CONTROL_STANDARD); - - CSettingsCategory* pvre = AddCategory(SETTINGS_PVR, "epg", 19069); - AddInt(pvre, "epg.defaultguideview", 19065, GUIDE_VIEW_TIMELINE, GUIDE_VIEW_CHANNEL, 1, GUIDE_VIEW_TIMELINE, SPIN_CONTROL_TEXT); - AddInt(pvre, "epg.daystodisplay", 19182, 3, 1, 1, 14, SPIN_CONTROL_INT_PLUS, MASK_DAYS); - AddSeparator(pvre, "epg.sep1"); - AddInt(pvre, "epg.epgupdate", 19071, 120, 15, 15, 2880, SPIN_CONTROL_INT_PLUS, MASK_MINS); - AddBool(pvre, "epg.preventupdateswhileplayingtv", 19230, false); - AddBool(pvre, "epg.ignoredbforclient", 19072, false); - AddBool(pvre, "epg.hidenoinfoavailable", 19268, true); - AddString(pvre, "epg.resetepg", 19187, "", BUTTON_CONTROL_STANDARD); - - CSettingsCategory* pvrp = AddCategory(SETTINGS_PVR, "pvrplayback", 19177); - AddBool(pvrp, "pvrplayback.playminimized", 19171, true); - AddInt(pvrp, "pvrplayback.startlast", 19189, START_LAST_CHANNEL_OFF, START_LAST_CHANNEL_OFF, 1, START_LAST_CHANNEL_ON, SPIN_CONTROL_TEXT); - AddBool(pvrp, "pvrplayback.signalquality", 19037, true); - AddSeparator(pvrp, "pvrplayback.sep1"); - AddInt(pvrp, "pvrplayback.scantime", 19170, 10, 1, 1, 60, SPIN_CONTROL_INT_PLUS, MASK_SECS); - AddBool(pvrp, "pvrplayback.confirmchannelswitch", 19281, false); - AddInt(pvrp, "pvrplayback.channelentrytimeout", 19073, 0, 0, 250, 10000, SPIN_CONTROL_INT_PLUS, MASK_MS); - - CSettingsCategory* pvrr = AddCategory(SETTINGS_PVR, "pvrrecord", 19043); - AddInt(pvrr, "pvrrecord.instantrecordtime", 19172, 120, 1, 1, 720, SPIN_CONTROL_INT_PLUS, MASK_MINS); - AddInt(pvrr, "pvrrecord.defaultpriority", 19173, 50, 1, 1, 100, SPIN_CONTROL_INT_PLUS); - AddInt(pvrr, "pvrrecord.defaultlifetime", 19174, 99, 1, 1, 365, SPIN_CONTROL_INT_PLUS, MASK_DAYS); - AddInt(pvrr, "pvrrecord.marginstart", 19175, 2, 0, 1, 60, SPIN_CONTROL_INT_PLUS, MASK_MINS); - AddInt(pvrr, "pvrrecord.marginend", 19176, 10, 0, 1, 60, SPIN_CONTROL_INT_PLUS, MASK_MINS); - AddSeparator(pvrr, "pvrrecord.sep1"); - AddBool(pvrr, "pvrrecord.timernotifications", 19233, true); - - CSettingsCategory* pvrpwr = AddCategory(SETTINGS_PVR, "pvrpowermanagement", 14095); - AddBool(pvrpwr, "pvrpowermanagement.enabled", 305, false); - AddSeparator(pvrpwr, "pvrpowermanagement.sep1"); - AddInt(pvrpwr, "pvrpowermanagement.backendidletime", 19244, 15, 0, 5, 360, SPIN_CONTROL_INT_PLUS, MASK_MINS, TEXT_OFF); - AddString(pvrpwr, "pvrpowermanagement.setwakeupcmd", 19245, "", EDIT_CONTROL_INPUT, true); - AddInt(pvrpwr, "pvrpowermanagement.prewakeup", 19246, 15, 0, 1, 60, SPIN_CONTROL_INT_PLUS, MASK_MINS, TEXT_OFF); - AddSeparator(pvrpwr, "pvrpowermanagement.sep2"); - AddBool(pvrpwr, "pvrpowermanagement.dailywakeup", 19247, false); - AddString(pvrpwr, "pvrpowermanagement.dailywakeuptime", 19248, "00:00:00", EDIT_CONTROL_INPUT); - - CSettingsCategory* pvrpa = AddCategory(SETTINGS_PVR, "pvrparental", 19259); - AddBool(pvrpa, "pvrparental.enabled", 449 , false); - AddSeparator(pvrpa, "pvrparental.sep1"); - AddString(pvrpa, "pvrparental.pin", 19261, "", EDIT_CONTROL_HIDDEN_NUMBER_VERIFY_NEW, true); - AddInt(pvrpa, "pvrparental.duration", 19260, 300, 5, 5, 1200, SPIN_CONTROL_INT_PLUS, MASK_SECS); - - CSettingsCategory* pvrc = AddCategory(SETTINGS_PVR, "pvrclient", 19279); - AddString(pvrc, "pvrclient.menuhook", 19280, "", BUTTON_CONTROL_STANDARD); -} - -CGUISettings::~CGUISettings(void) -{ - Clear(); -} - -void CGUISettings::AddGroup(int groupID, int labelID) -{ - CSettingsGroup *pGroup = new CSettingsGroup(groupID, labelID); - if (pGroup) - settingsGroups.push_back(pGroup); -} - -CSettingsCategory* CGUISettings::AddCategory(int groupID, const char *strSetting, int labelID) -{ - for (unsigned int i = 0; i < settingsGroups.size(); i++) - { - if (settingsGroups[i]->GetGroupID() == groupID) - return settingsGroups[i]->AddCategory(CStdString(strSetting).ToLower(), labelID); - } - return NULL; -} - -CSettingsGroup *CGUISettings::GetGroup(int groupID) -{ - for (unsigned int i = 0; i < settingsGroups.size(); i++) - { - if (settingsGroups[i]->GetGroupID() == groupID) - return settingsGroups[i]; - } - CLog::Log(LOGDEBUG, "Error: Requested setting group (%i) was not found. " - "It must be case-sensitive", - groupID); - return NULL; -} - -void CGUISettings::AddSetting(CSettingsCategory* cat, CSetting* setting) -{ - if (!setting) - return; - - if (cat) - cat->m_settings.push_back(setting); - settingsMap.insert(pair(CStdString(setting->GetSetting()).ToLower(), setting)); -} - -void CGUISettings::AddSeparator(CSettingsCategory* cat, const char *strSetting) -{ - int iOrder = cat ? cat->m_settings.size() : 0; - CSettingSeparator *pSetting = new CSettingSeparator(iOrder, CStdString(strSetting).ToLower()); - if (!pSetting) return; - AddSetting(cat, pSetting); -} - -void CGUISettings::AddBool(CSettingsCategory* cat, const char *strSetting, int iLabel, bool bData, int iControlType) -{ - int iOrder = cat ? cat->m_settings.size() : 0; - CSettingBool* pSetting = new CSettingBool(iOrder, CStdString(strSetting).ToLower(), iLabel, bData, iControlType); - if (!pSetting) return ; - AddSetting(cat, pSetting); -} - -bool CGUISettings::GetBool(const char *strSetting) const -{ - ASSERT(settingsMap.size()); - constMapIter it = settingsMap.find(strSetting); - if (it != settingsMap.end()) - { // old category - return ((CSettingBool*)(*it).second)->GetData(); - } - // Backward compatibility (skins use this setting) - if (strncmp(strSetting, "lookandfeel.enablemouse", 23) == 0) - return GetBool("input.enablemouse"); - // Assert here and write debug output - CLog::Log(LOGDEBUG,"Error: Requested setting (%s) was not found. It must be case-sensitive", strSetting); - return false; -} - -void CGUISettings::SetBool(const char *strSetting, bool bSetting) -{ - ASSERT(settingsMap.size()); - mapIter it = settingsMap.find(strSetting); - if (it != settingsMap.end()) - { // old category - ((CSettingBool*)(*it).second)->SetData(bSetting); - - SetChanged(); - - return ; - } - // Assert here and write debug output - CLog::Log(LOGDEBUG,"Error: Requested setting (%s) was not found. It must be case-sensitive", strSetting); -} - -void CGUISettings::ToggleBool(const char *strSetting) -{ - ASSERT(settingsMap.size()); - mapIter it = settingsMap.find(CStdString(strSetting).ToLower()); - if (it != settingsMap.end()) - { // old category - ((CSettingBool*)(*it).second)->SetData(!((CSettingBool *)(*it).second)->GetData()); - - SetChanged(); - - return ; - } - // Assert here and write debug output - CLog::Log(LOGDEBUG,"Error: Requested setting (%s) was not found. It must be case-sensitive", strSetting); -} - -void CGUISettings::AddFloat(CSettingsCategory* cat, const char *strSetting, int iLabel, float fData, float fMin, float fStep, float fMax, int iControlType) -{ - int iOrder = cat ? cat->m_settings.size() : 0; - CSettingFloat* pSetting = new CSettingFloat(iOrder, CStdString(strSetting).ToLower(), iLabel, fData, fMin, fStep, fMax, iControlType); - if (!pSetting) return ; - AddSetting(cat, pSetting); -} - -float CGUISettings::GetFloat(const char *strSetting) const -{ - ASSERT(settingsMap.size()); - constMapIter it = settingsMap.find(strSetting); - if (it != settingsMap.end()) - { - return ((CSettingFloat *)(*it).second)->GetData(); - } - // Assert here and write debug output - //ASSERT(false); - CLog::Log(LOGDEBUG,"Error: Requested setting (%s) was not found. It must be case-sensitive", strSetting); - return 0.0f; -} - -void CGUISettings::SetFloat(const char *strSetting, float fSetting) -{ - ASSERT(settingsMap.size()); - mapIter it = settingsMap.find(strSetting); - if (it != settingsMap.end()) - { - ((CSettingFloat *)(*it).second)->SetData(fSetting); - - SetChanged(); - - return ; - } - // Assert here and write debug output - ASSERT(false); - CLog::Log(LOGDEBUG,"Error: Requested setting (%s) was not found. It must be case-sensitive", strSetting); -} - -void CGUISettings::LoadMasterLock(TiXmlElement *pRootElement) -{ - mapIter it = settingsMap.find("masterlock.maxretries"); - if (it != settingsMap.end()) - LoadFromXML(pRootElement, it); - it = settingsMap.find("masterlock.startuplock"); - if (it != settingsMap.end()) - LoadFromXML(pRootElement, it); -} - -void CGUISettings::AddInt(CSettingsCategory* cat, const char *strSetting, int iLabel, int iData, int iMin, int iStep, int iMax, int iControlType, const char *strFormat) -{ - int iOrder = cat ? cat->m_settings.size() : 0; - CSettingInt* pSetting = new CSettingInt(iOrder, CStdString(strSetting).ToLower(), iLabel, iData, iMin, iStep, iMax, iControlType, strFormat); - if (!pSetting) return ; - AddSetting(cat, pSetting); -} - -void CGUISettings::AddInt(CSettingsCategory* cat, const char *strSetting, int iLabel, int iData, int iMin, int iStep, int iMax, int iControlType, int iFormat, int iLabelMin/*=-1*/) -{ - int iOrder = cat ? cat->m_settings.size() : 0; - CSettingInt* pSetting = new CSettingInt(iOrder, CStdString(strSetting).ToLower(), iLabel, iData, iMin, iStep, iMax, iControlType, iFormat, iLabelMin); - if (!pSetting) return ; - AddSetting(cat, pSetting); -} - -void CGUISettings::AddInt(CSettingsCategory* cat, const char *strSetting, int iLabel, int iData, const map& entries, int iControlType) -{ - int iOrder = cat ? cat->m_settings.size() : 0; - CSettingInt* pSetting = new CSettingInt(iOrder, CStdString(strSetting).ToLower(), iLabel, iData, entries, iControlType); - if (!pSetting) return ; - AddSetting(cat, pSetting); -} - -void CGUISettings::AddHex(CSettingsCategory* cat, const char *strSetting, int iLabel, int iData, int iMin, int iStep, int iMax, int iControlType, const char *strFormat) -{ - int iOrder = cat ? cat->m_settings.size() : 0; - CSettingHex* pSetting = new CSettingHex(iOrder, CStdString(strSetting).ToLower(), iLabel, iData, iMin, iStep, iMax, iControlType, strFormat); - if (!pSetting) return ; - AddSetting(cat, pSetting); -} - -int CGUISettings::GetInt(const char *strSetting) const -{ - ASSERT(settingsMap.size()); - - constMapIter it = settingsMap.find(strSetting); - if (it != settingsMap.end()) - { - return ((CSettingInt *)(*it).second)->GetData(); - } - // Assert here and write debug output - CLog::Log(LOGERROR,"Error: Requested setting (%s) was not found. It must be case-sensitive", strSetting); - //ASSERT(false); - return 0; -} - -void CGUISettings::SetInt(const char *strSetting, int iSetting) -{ - ASSERT(settingsMap.size()); - mapIter it = settingsMap.find(strSetting); - if (it != settingsMap.end()) - { - ((CSettingInt *)(*it).second)->SetData(iSetting); - - SetChanged(); - - return ; - } - // Assert here and write debug output - ASSERT(false); -} - -void CGUISettings::AddString(CSettingsCategory* cat, const char *strSetting, int iLabel, const char *strData, int iControlType, bool bAllowEmpty, int iHeadingString) -{ - int iOrder = cat ? cat->m_settings.size() : 0; - CSettingString* pSetting = new CSettingString(iOrder, CStdString(strSetting).ToLower(), iLabel, strData, iControlType, bAllowEmpty, iHeadingString); - if (!pSetting) return ; - AddSetting(cat, pSetting); -} - -void CGUISettings::AddPath(CSettingsCategory* cat, const char *strSetting, int iLabel, const char *strData, int iControlType, bool bAllowEmpty, int iHeadingString) -{ - int iOrder = cat ? cat->m_settings.size() : 0; - CSettingPath* pSetting = new CSettingPath(iOrder, CStdString(strSetting).ToLower(), iLabel, strData, iControlType, bAllowEmpty, iHeadingString); - if (!pSetting) return ; - AddSetting(cat, pSetting); -} - -void CGUISettings::AddDefaultAddon(CSettingsCategory* cat, const char *strSetting, int iLabel, const char *strData, const TYPE type) -{ - int iOrder = cat ? cat->m_settings.size() : 0; - CSettingAddon* pSetting = new CSettingAddon(iOrder, CStdString(strSetting).ToLower(), iLabel, strData, type); - if (!pSetting) return ; - AddSetting(cat, pSetting); -} - -const CStdString &CGUISettings::GetString(const char *strSetting, bool bPrompt /* = true */) const -{ - ASSERT(settingsMap.size()); - constMapIter it = settingsMap.find(strSetting); - if (it != settingsMap.end()) - { - CSettingString* result = ((CSettingString *)(*it).second); - if (result->GetData() == "select folder" || result->GetData() == "select writable folder") - { - CStdString strData = ""; - if (bPrompt) - { - VECSOURCES shares; - g_mediaManager.GetLocalDrives(shares); - if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares,g_localizeStrings.Get(result->GetLabel()),strData,result->GetData() == "select writable folder")) - { - result->SetData(strData); - g_settings.Save(); - } - else - return StringUtils::EmptyString; - } - else - return StringUtils::EmptyString; - } - return result->GetData(); - } - // Assert here and write debug output - CLog::Log(LOGDEBUG,"Error: Requested setting (%s) was not found. It must be case-sensitive", strSetting); - //ASSERT(false); - // hardcoded return value so that compiler is happy - return StringUtils::EmptyString; -} - -void CGUISettings::SetString(const char *strSetting, const char *strData) -{ - ASSERT(settingsMap.size()); - mapIter it = settingsMap.find(strSetting); - if (it != settingsMap.end()) - { - ((CSettingString *)(*it).second)->SetData(strData); - - SetChanged(); - - return ; - } - // Assert here and write debug output - ASSERT(false); - CLog::Log(LOGDEBUG,"Error: Requested setting (%s) was not found. It must be case-sensitive", strSetting); -} - -CSetting *CGUISettings::GetSetting(const char *strSetting) -{ - ASSERT(settingsMap.size()); - mapIter it = settingsMap.find(strSetting); - if (it != settingsMap.end()) - return (*it).second; - else - return NULL; -} - -// get all the settings beginning with the term "strGroup" -void CGUISettings::GetSettingsGroup(CSettingsCategory* cat, vecSettings &settings) -{ - if (!cat || cat->m_settings.size() <= 0) - return; - - vecSettings unorderedSettings; - for (unsigned int index = 0; index < cat->m_settings.size(); index++) - { - if (!cat->m_settings.at(index)->IsAdvanced()) - unorderedSettings.push_back(cat->m_settings.at(index)); - } - - // now order them... - sort(unorderedSettings.begin(), unorderedSettings.end(), sortsettings()); - - // remove any instances of 2 separators in a row - bool lastWasSeparator(false); - for (vecSettings::iterator it = unorderedSettings.begin(); it != unorderedSettings.end(); it++) - { - CSetting *setting = *it; - // only add separators if we don't have 2 in a row - if (setting->GetType() == SETTINGS_TYPE_SEPARATOR) - { - if (!lastWasSeparator) - settings.push_back(setting); - lastWasSeparator = true; - } - else - { - lastWasSeparator = false; - settings.push_back(setting); - } - } -} - -void CGUISettings::LoadXML(TiXmlElement *pRootElement, bool hideSettings /* = false */) -{ // load our stuff... - bool updated = false; - - for (mapIter it = settingsMap.begin(); it != settingsMap.end(); it++) - { - LoadFromXML(pRootElement, it, hideSettings); - } - - // check if we are updating to Frodo and need to update from - // audiooutput.channellayout to audiooutput.channels - TiXmlNode *channelNode = pRootElement->FirstChild("audiooutput"); - if (channelNode != NULL) - { - channelNode = channelNode->FirstChild("channellayout"); - CSettingInt* channels = (CSettingInt*)GetSetting("audiooutput.channels"); - if (channelNode != NULL && channelNode->FirstChild() != NULL && channels != NULL) - { - channels->FromString(channelNode->FirstChild()->ValueStr()); - if (channels->GetData() < AE_CH_LAYOUT_MAX - 1) - channels->SetData(channels->GetData() + 1); - - // let's just reset the audiodevice settings as well - std::string audiodevice = GetString("audiooutput.audiodevice"); - CAEFactory::VerifyOutputDevice(audiodevice, false); - SetString("audiooutput.audiodevice", audiodevice.c_str()); - - updated = true; - } - } - - // and fix the videoscreen.screenmode if necessary - std::string screenmode = GetString("videoscreen.screenmode"); - // in Eden there was no character ("i" or "p") indicating interlaced/progressive - // at the end so we just add a "p" and assume progressive - if (screenmode.size() == 20) - { - screenmode += "p"; - SetString("videoscreen.screenmode", screenmode.c_str()); - updated = true; - } - - // Get hardware based stuff... - CLog::Log(LOGNOTICE, "Getting hardware information now..."); - // FIXME: Check if the hardware supports it (if possible ;) - //SetBool("audiooutput.ac3passthrough", g_audioConfig.GetAC3Enabled()); - //SetBool("audiooutput.dtspassthrough", g_audioConfig.GetDTSEnabled()); - CLog::Log(LOGINFO, "Using %s output", GetInt("audiooutput.mode") == AUDIO_ANALOG ? "analog" : "digital"); - CLog::Log(LOGINFO, "AC3 pass through is %s", GetBool("audiooutput.ac3passthrough") ? "enabled" : "disabled"); - CLog::Log(LOGINFO, "DTS pass through is %s", GetBool("audiooutput.dtspassthrough") ? "enabled" : "disabled"); - CLog::Log(LOGINFO, "AAC pass through is %s", GetBool("audiooutput.passthroughaac") ? "enabled" : "disabled"); - -#if defined(TARGET_DARWIN) - // trap any previous vsync by driver setting, does not exist on OSX - if (GetInt("videoscreen.vsync") == VSYNC_DRIVER) - { - SetInt("videoscreen.vsync", VSYNC_ALWAYS); - } -#endif - - // map old vpdau color range, to now global setting - if (GetBool("videoplayer.vdpaustudiolevel")) - { - SetBool("videoscreen.limitedrange", true); - SetBool("videoplayer.vdpaustudiolevel", false); - } - // DXMERGE: This might have been useful? - // g_videoConfig.SetVSyncMode((VSYNC)GetInt("videoscreen.vsync")); - - // Move replaygain settings into our struct - ReplayGainSettings &replayGainSettings = CAudioDecoder::GetReplayGainSettings(); - replayGainSettings.iPreAmp = GetInt("musicplayer.replaygainpreamp"); - replayGainSettings.iNoGainPreAmp = GetInt("musicplayer.replaygainnogainpreamp"); - replayGainSettings.iType = GetInt("musicplayer.replaygaintype"); - replayGainSettings.bAvoidClipping = GetBool("musicplayer.replaygainavoidclipping"); - - bool use_timezone = false; - -#if defined(_LINUX) -#if defined(TARGET_DARWIN) - if (g_sysinfo.IsAppleTV2() && GetIOSVersion() < 4.3) -#endif -#if !defined(TARGET_ANDROID) - use_timezone = true; -#endif - - if (use_timezone) - { - CStdString timezone = GetString("locale.timezone"); - if(timezone == "0" || timezone.IsEmpty()) - { - timezone = g_timezone.GetOSConfiguredTimezone(); - SetString("locale.timezone", timezone); - updated = true; - } - g_timezone.SetTimezone(timezone); - } -#endif - - CStdString streamLanguage = GetString("locale.audiolanguage"); - if (!streamLanguage.Equals("original") && !streamLanguage.Equals("default")) - g_langInfo.SetAudioLanguage(streamLanguage); - else - g_langInfo.SetAudioLanguage(""); - - streamLanguage = GetString("locale.subtitlelanguage"); - if (!streamLanguage.Equals("original") && !streamLanguage.Equals("default")) - g_langInfo.SetSubtitleLanguage(streamLanguage); - else - g_langInfo.SetSubtitleLanguage(""); - - // we no longer ship the built-in slideshow screensaver, replace it if it's still in use - if (GetString("screensaver.mode") == "screensaver.xbmc.builtin.slideshow") - { - SetString("screensaver.mode", "screensaver.xbmc.builtin.dim"); - updated = true; - } - - // replace broken last.fm musicvideo scraper with theaudiodb.com if it's still in use - if (GetString("scrapers.musicvideosdefault") == "metadata.musicvideos.last.fm") - { - SetString("scrapers.musicvideosdefault", "metadata.musicvideos.theaudiodb.com"); - updated = true; - } - - if (updated) - g_settings.Save(); -} - -void CGUISettings::LoadFromXML(TiXmlElement *pRootElement, mapIter &it, bool advanced /* = false */) -{ - CStdStringArray strSplit; - StringUtils::SplitString((*it).first, ".", strSplit); - if (strSplit.size() > 1) - { - const TiXmlNode *pChild = pRootElement->FirstChild(strSplit[0].c_str()); - if (pChild) - { - const TiXmlElement *pGrandChild = pChild->FirstChildElement(strSplit[1].c_str()); - if (pGrandChild) - { - CStdString strValue = pGrandChild->FirstChild() ? pGrandChild->FirstChild()->Value() : ""; - if (strValue != "-") - { // update our item - (*it).second->FromString(strValue); - if (advanced) - (*it).second->SetAdvanced(); - } - } - } - } - - SetChanged(); -} - -void CGUISettings::SaveXML(TiXmlNode *pRootNode) -{ - for (mapIter it = settingsMap.begin(); it != settingsMap.end(); it++) - { - // don't save advanced settings - CStdString first = (*it).first; - if ((*it).second->IsAdvanced() || (*it).second->GetType() == SETTINGS_TYPE_SEPARATOR) - continue; - - CStdStringArray strSplit; - StringUtils::SplitString((*it).first, ".", strSplit); - if (strSplit.size() > 1) - { - TiXmlNode *pChild = pRootNode->FirstChild(strSplit[0].c_str()); - if (!pChild) - { // add our group tag - TiXmlElement newElement(strSplit[0].c_str()); - pChild = pRootNode->InsertEndChild(newElement); - } - - if (pChild) - { // successfully added (or found) our group - TiXmlElement newElement(strSplit[1]); - if ((*it).second->GetType() == SETTINGS_TYPE_PATH) - newElement.SetAttribute("pathversion", XMLUtils::path_version); - TiXmlNode *pNewNode = pChild->InsertEndChild(newElement); - if (pNewNode) - { - TiXmlText value((*it).second->ToString()); - pNewNode->InsertEndChild(value); - } - } - } - } - - SetChanged(); -} - -void CGUISettings::Clear() -{ - for (mapIter it = settingsMap.begin(); it != settingsMap.end(); it++) - delete (*it).second; - settingsMap.clear(); - for (unsigned int i = 0; i < settingsGroups.size(); i++) - delete settingsGroups[i]; - settingsGroups.clear(); - - SetChanged(); -} diff --git a/xbmc/settings/GUISettings.h b/xbmc/settings/GUISettings.h deleted file mode 100644 index dd71c1faa4e5b..0000000000000 --- a/xbmc/settings/GUISettings.h +++ /dev/null @@ -1,511 +0,0 @@ -#pragma once - -/* - * Copyright (C) 2005-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 - * . - * - */ - -#include -#include -#include "guilib/Resolution.h" -#include "addons/IAddon.h" -#include "utils/Observer.h" -#include "utils/GlobalsHandling.h" - -//FIXME - after eden - make that one nicer somehow... -#if defined(TARGET_DARWIN_IOS) && !defined(TARGET_DARWIN_IOS_ATV2) -#include "system.h" //for HAS_SKIN_TOUCHED -#endif - -#if defined(HAS_SKIN_TOUCHED) && defined(TARGET_DARWIN_IOS) && !defined(TARGET_DARWIN_IOS_ATV2) -#define DEFAULT_SKIN "skin.touched" -#else -#define DEFAULT_SKIN "skin.confluence" -#endif - -class TiXmlNode; -class TiXmlElement; - -// Render Methods -#define RENDER_METHOD_AUTO 0 -#define RENDER_METHOD_ARB 1 -#define RENDER_METHOD_GLSL 2 -#define RENDER_METHOD_SOFTWARE 3 -#define RENDER_METHOD_D3D_PS 4 -#define RENDER_METHOD_DXVA 5 -#define RENDER_OVERLAYS 99 // to retain compatibility - -// Scaling options. -#define SOFTWARE_UPSCALING_DISABLED 0 -#define SOFTWARE_UPSCALING_SD_CONTENT 1 -#define SOFTWARE_UPSCALING_ALWAYS 2 - -// Apple Remote options. -#define APPLE_REMOTE_DISABLED 0 -#define APPLE_REMOTE_STANDARD 1 -#define APPLE_REMOTE_UNIVERSAL 2 -#define APPLE_REMOTE_MULTIREMOTE 3 - -// Subtitle colours - -#define SUBTITLE_COLOR_START 0 -#define SUBTITLE_COLOR_END 7 - -// Karaoke colours - -// If you want to add more colors, it should be done the following way: -// 1. Increase KARAOKE_COLOR_END -// 2. Add a new color description in language/English/strings.xml in block -// with id 22040 + KARAOKE_COLOR_END value -// 3. Add a new color hex mask into gLyricColors structure in karaoke/karaokelyricstext.cpp -#define KARAOKE_COLOR_START 0 -#define KARAOKE_COLOR_END 4 - -// CDDA Autoaction defines -#define AUTOCD_NONE 0 -#define AUTOCD_PLAY 1 -#define AUTOCD_RIP 2 - -// CDDA ripper defines -#define CDDARIP_ENCODER_LAME 0 -#define CDDARIP_ENCODER_VORBIS 1 -#define CDDARIP_ENCODER_WAV 2 -#define CDDARIP_ENCODER_FLAC 3 - -#define CDDARIP_QUALITY_CBR 0 -#define CDDARIP_QUALITY_MEDIUM 1 -#define CDDARIP_QUALITY_STANDARD 2 -#define CDDARIP_QUALITY_EXTREME 3 - -#define AUDIO_ANALOG 0 -#define AUDIO_IEC958 1 -#define AUDIO_HDMI 2 -#define AUDIO_COUNT 3 -#define AUDIO_IS_BITSTREAM(x) ((x) == AUDIO_IEC958 || (x) == AUDIO_HDMI) - -#define VIDEO_NORMAL 0 -#define VIDEO_LETTERBOX 1 -#define VIDEO_WIDESCREEN 2 - -#define MODCHIP_SMARTXX 0 -#define MODCHIP_XENIUM 1 -#define MODCHIP_XECUTER3 2 - -// LED settings -#define LED_COLOUR_NO_CHANGE 0 -#define LED_COLOUR_GREEN 1 -#define LED_COLOUR_ORANGE 2 -#define LED_COLOUR_RED 3 -#define LED_COLOUR_CYCLE 4 -#define LED_COLOUR_OFF 5 - -#define FRAME_RATE_LEAVE_AS_IS 0 -#define FRAME_RATE_CONVERT 1 -#define FRAME_RATE_USE_PAL60 2 - -#define LED_PLAYBACK_OFF 0 -#define LED_PLAYBACK_VIDEO 1 -#define LED_PLAYBACK_MUSIC 2 -#define LED_PLAYBACK_VIDEO_MUSIC 3 - -#define SPIN_DOWN_NONE 0 -#define SPIN_DOWN_MUSIC 1 -#define SPIN_DOWN_VIDEO 2 -#define SPIN_DOWN_BOTH 3 - -#define AAM_QUIET 1 -#define AAM_FAST 0 - -#define APM_HIPOWER 0 -#define APM_LOPOWER 1 -#define APM_HIPOWER_STANDBY 2 -#define APM_LOPOWER_STANDBY 3 - -#define GUIDE_VIEW_CHANNEL 0 -#define GUIDE_VIEW_NOW 1 -#define GUIDE_VIEW_NEXT 2 -#define GUIDE_VIEW_TIMELINE 3 - -#define START_LAST_CHANNEL_OFF 0 -#define START_LAST_CHANNEL_MIN 1 -#define START_LAST_CHANNEL_ON 2 - -#define SETTINGS_TYPE_BOOL 1 -#define SETTINGS_TYPE_FLOAT 2 -#define SETTINGS_TYPE_INT 3 -#define SETTINGS_TYPE_STRING 4 -#define SETTINGS_TYPE_HEX 5 -#define SETTINGS_TYPE_SEPARATOR 6 -#define SETTINGS_TYPE_PATH 7 -#define SETTINGS_TYPE_ADDON 8 - -#define CHECKMARK_CONTROL 1 -#define SPIN_CONTROL_FLOAT 2 -#define SPIN_CONTROL_INT 3 -#define SPIN_CONTROL_INT_PLUS 4 -#define SPIN_CONTROL_TEXT 5 -#define EDIT_CONTROL_INPUT 6 -#define EDIT_CONTROL_HIDDEN_INPUT 7 -#define EDIT_CONTROL_NUMBER_INPUT 8 -#define EDIT_CONTROL_IP_INPUT 9 -#define EDIT_CONTROL_MD5_INPUT 10 -#define BUTTON_CONTROL_STANDARD 11 -#define BUTTON_CONTROL_MISC_INPUT 12 -#define BUTTON_CONTROL_PATH_INPUT 13 -#define SEPARATOR_CONTROL 14 -#define EDIT_CONTROL_HIDDEN_NUMBER_VERIFY_NEW 15 - -#define REPLAY_GAIN_NONE 0 -#define REPLAY_GAIN_ALBUM 1 -#define REPLAY_GAIN_TRACK 2 - -//AV sync options -#define SYNC_DISCON 0 -#define SYNC_SKIPDUP 1 -#define SYNC_RESAMPLE 2 - -//adjust refreshrate options -#define ADJUST_REFRESHRATE_OFF 0 -#define ADJUST_REFRESHRATE_ALWAYS 1 -#define ADJUST_REFRESHRATE_ON_STARTSTOP 2 - - -//resampler quality -#define RESAMPLE_LOW 0 -#define RESAMPLE_MID 1 -#define RESAMPLE_HIGH 2 -#define RESAMPLE_REALLYHIGH 3 - -//0.1 second increments -#define MAXREFRESHCHANGEDELAY 200 - -enum PowerState -{ - POWERSTATE_QUIT = 0, - POWERSTATE_SHUTDOWN, - POWERSTATE_HIBERNATE, - POWERSTATE_SUSPEND, - POWERSTATE_REBOOT, - POWERSTATE_MINIMIZE, - POWERSTATE_NONE, - POWERSTATE_ASK -}; - -enum VideoSelectAction -{ - SELECT_ACTION_CHOOSE = 0, - SELECT_ACTION_PLAY_OR_RESUME, - SELECT_ACTION_RESUME, - SELECT_ACTION_INFO, - SELECT_ACTION_MORE, - SELECT_ACTION_PLAY, - SELECT_ACTION_PLAYPART -}; - -enum SubtitleAlign -{ - SUBTITLE_ALIGN_MANUAL = 0, - SUBTITLE_ALIGN_BOTTOM_INSIDE, - SUBTITLE_ALIGN_BOTTOM_OUTSIDE, - SUBTITLE_ALIGN_TOP_INSIDE, - SUBTITLE_ALIGN_TOP_OUTSIDE -}; - -// base class for all settings types -class CSetting -{ -public: - CSetting(int iOrder, const char *strSetting, int iLabel, int iControlType) { - m_iOrder = iOrder; - m_strSetting = strSetting; - m_iLabel = iLabel; - m_iControlType = iControlType; - m_advanced = false; - m_visible = true; - }; - virtual ~CSetting() {}; - virtual int GetType() const { return 0; }; - int GetControlType() const { return m_iControlType; }; - virtual void FromString(const CStdString &strValue) {}; - virtual CStdString ToString() const { return ""; }; - const char *GetSetting() const { return m_strSetting.c_str(); }; - int GetLabel() const { return m_iLabel; }; - int GetOrder() const { return m_iOrder; }; - void SetOrder(int iOrder) { m_iOrder = iOrder; }; - void SetAdvanced() { m_advanced = true; }; - bool IsAdvanced() const { return m_advanced; }; - // A setting might be invisible in the current session, yet carried over - // in the config file. - void SetVisible(bool visible) { m_visible = visible; } - bool IsVisible() const { return m_visible; } -private: - int m_iControlType; - int m_iLabel; - int m_iOrder; - bool m_advanced; - bool m_visible; - CStdString m_strSetting; -}; - -class CSettingBool : public CSetting -{ -public: - CSettingBool(int iOrder, const char *strSetting, int iLabel, bool bData, int iControlType): CSetting(iOrder, strSetting, iLabel, iControlType) { m_bData = bData; }; - virtual ~CSettingBool() {}; - - virtual int GetType() const { return SETTINGS_TYPE_BOOL; }; - virtual void FromString(const CStdString &strValue); - virtual CStdString ToString() const; - - void SetData(bool bData) { m_bData = bData; }; - bool GetData() const { return m_bData; }; - -private: - bool m_bData; -}; - -class CSettingFloat : public CSetting -{ -public: - CSettingFloat(int iOrder, const char *strSetting, int iLabel, float fData, float fMin, float fStep, float fMax, int iControlType); - virtual ~CSettingFloat() {}; - - virtual int GetType() const { return SETTINGS_TYPE_FLOAT; }; - virtual void FromString(const CStdString &strValue); - virtual CStdString ToString() const; - - void SetData(float fData) { m_fData = fData; if (m_fData < m_fMin) m_fData = m_fMin; if (m_fData > m_fMax) m_fData = m_fMax;}; - float GetData() const { return m_fData; }; - - float m_fMin; - float m_fStep; - float m_fMax; - -private: - float m_fData; -}; - -class CSettingInt : public CSetting -{ -public: - CSettingInt(int iOrder, const char *strSetting, int iLabel, int iData, int iMin, int iStep, int iMax, int iControlType, const char *strFormat); - CSettingInt(int iOrder, const char *strSetting, int iLabel, int iData, int iMin, int iStep, int iMax, int iControlType, int iFormat, int iLabelMin); - CSettingInt(int iOrder, const char *strSetting, int iLabel, int iData, const std::map& entries, int iControlType); - virtual ~CSettingInt() {}; - - virtual int GetType() const { return SETTINGS_TYPE_INT; }; - virtual void FromString(const CStdString &strValue); - virtual CStdString ToString() const; - - void SetData(int iData) - { - if (m_entries.empty()) - { - m_iData = iData; - if (m_iData < m_iMin) m_iData = m_iMin; - if (m_iData > m_iMax) m_iData = m_iMax; - } - else - { - //if the setting is an std::map, check if iData is a valid value before assigning it - for (std::map::iterator it = m_entries.begin(); it != m_entries.end(); it++) - { - if (it->second == iData) - { - m_iData = iData; - break; - } - } - } - } - int GetData() const { return m_iData; }; - - int m_iMin; - int m_iStep; - int m_iMax; - int m_iFormat; - int m_iLabelMin; - CStdString m_strFormat; - std::map m_entries; - -protected: - int m_iData; -}; - -class CSettingHex : public CSettingInt -{ -public: - CSettingHex(int iOrder, const char *strSetting, int iLabel, int iData, int iMin, int iStep, int iMax, int iControlType, const char *strFormat) - : CSettingInt(iOrder, strSetting, iLabel, iData, iMin, iStep, iMax, iControlType, strFormat) {}; - virtual ~CSettingHex() {}; - virtual void FromString(const CStdString &strValue); - virtual CStdString ToString() const; - virtual int GetType() const { return SETTINGS_TYPE_HEX; }; -}; - -class CSettingString : public CSetting -{ -public: - CSettingString(int iOrder, const char *strSetting, int iLabel, const char *strData, int iControlType, bool bAllowEmpty, int iHeadingString); - virtual ~CSettingString() {}; - - virtual int GetType() const { return SETTINGS_TYPE_STRING; }; - virtual void FromString(const CStdString &strValue); - virtual CStdString ToString() const; - - void SetData(const char *strData) { m_strData = strData; }; - const CStdString &GetData() const { return m_strData; }; - - bool m_bAllowEmpty; - int m_iHeadingString; -private: - CStdString m_strData; -}; - -class CSettingPath : public CSettingString -{ -public: - CSettingPath(int iOrder, const char *strSetting, int iLabel, const char *strData, int iControlType, bool bAllowEmpty, int iHeadingString); - virtual ~CSettingPath() {}; - - virtual int GetType() const { return SETTINGS_TYPE_PATH; }; -}; - -class CSettingAddon : public CSettingString -{ -public: - CSettingAddon(int iOrder, const char *strSetting, int iLabel, const char *strData, const ADDON::TYPE type); - virtual ~CSettingAddon() {}; - virtual int GetType() const { return SETTINGS_TYPE_ADDON; }; - - const ADDON::TYPE m_type; -}; - -class CSettingSeparator : public CSetting -{ -public: - CSettingSeparator(int iOrder, const char *strSetting); - virtual ~CSettingSeparator() {}; - - virtual int GetType() const { return SETTINGS_TYPE_SEPARATOR; }; -}; - -class CSettingsCategory -{ -public: - CSettingsCategory(const char *strCategory, int labelID) - { - m_strCategory = strCategory; - m_labelID = labelID; - } - ~CSettingsCategory() {}; - - CStdString m_strCategory; - int m_labelID; - std::vector m_settings; -}; - -typedef std::vector vecSettingsCategory; - -class CSettingsGroup -{ -public: - CSettingsGroup(int groupID, int labelID) - { - m_groupID = groupID; - m_labelID = labelID; - } - ~CSettingsGroup() - { - for (unsigned int i = 0; i < m_vecCategories.size(); i++) - delete m_vecCategories[i]; - m_vecCategories.clear(); - }; - - CSettingsCategory* AddCategory(const char *strCategory, int labelID); - void GetCategories(vecSettingsCategory &vecCategories); - int GetLabelID() { return m_labelID; }; - int GetGroupID() { return m_groupID; }; -private: - vecSettingsCategory m_vecCategories; - int m_groupID; - int m_labelID; -}; - -typedef std::vector vecSettings; - -class CGUISettings : public Observable -{ -public: - CGUISettings(); - ~CGUISettings(); - - void Initialize(); - - void AddGroup(int groupID, int labelID); - CSettingsCategory* AddCategory(int groupID, const char *strCategory, int labelID); - CSettingsGroup *GetGroup(int windowID); - - void AddSetting(CSettingsCategory* cat, CSetting* setting); - void AddBool(CSettingsCategory* cat, const char *strSetting, int iLabel, bool bSetting, int iControlType = CHECKMARK_CONTROL); - bool GetBool(const char *strSetting) const; - void SetBool(const char *strSetting, bool bSetting); - void ToggleBool(const char *strSetting); - - void AddFloat(CSettingsCategory* cat, const char *strSetting, int iLabel, float fSetting, float fMin, float fStep, float fMax, int iControlType = SPIN_CONTROL_FLOAT); - float GetFloat(const char *strSetting) const; - void SetFloat(const char *strSetting, float fSetting); - - void AddInt(CSettingsCategory* cat, const char *strSetting, int iLabel, int fSetting, int iMin, int iStep, int iMax, int iControlType, const char *strFormat = NULL); - void AddInt(CSettingsCategory* cat, const char *strSetting, int iLabel, int iData, int iMin, int iStep, int iMax, int iControlType, int iFormat, int iLabelMin=-1); - void AddInt(CSettingsCategory* cat, const char *strSetting, int iLabel, int iData, const std::map& entries, int iControlType); - void AddSpin(unsigned int id, int label, int *current, std::vector > &values); - int GetInt(const char *strSetting) const; - void SetInt(const char *strSetting, int fSetting); - - void AddHex(CSettingsCategory* cat, const char *strSetting, int iLabel, int fSetting, int iMin, int iStep, int iMax, int iControlType, const char *strFormat = NULL); - - void AddString(CSettingsCategory* cat, const char *strSetting, int iLabel, const char *strData, int iControlType = EDIT_CONTROL_INPUT, bool bAllowEmpty = false, int iHeadingString = -1); - void AddPath(CSettingsCategory* cat, const char *strSetting, int iLabel, const char *strData, int iControlType = EDIT_CONTROL_INPUT, bool bAllowEmpty = false, int iHeadingString = -1); - - void AddDefaultAddon(CSettingsCategory* cat, const char *strSetting, int iLabel, const char *strData, const ADDON::TYPE type); - - const CStdString &GetString(const char *strSetting, bool bPrompt=true) const; - void SetString(const char *strSetting, const char *strData); - - void AddSeparator(CSettingsCategory* cat, const char *strSetting); - - CSetting *GetSetting(const char *strSetting); - - void GetSettingsGroup(CSettingsCategory* cat, vecSettings &settings); - void LoadXML(TiXmlElement *pRootElement, bool hideSettings = false); - void SaveXML(TiXmlNode *pRootNode); - void LoadMasterLock(TiXmlElement *pRootElement); - - void Clear(); - -private: - typedef std::map::iterator mapIter; - typedef std::map::const_iterator constMapIter; - std::map settingsMap; - std::vector settingsGroups; - void LoadFromXML(TiXmlElement *pRootElement, mapIter &it, bool advanced = false); -}; - -XBMC_GLOBAL_REF(CGUISettings, g_guiSettings); -#define g_guiSettings XBMC_GLOBAL_USE(CGUISettings) diff --git a/xbmc/settings/ISetting.cpp b/xbmc/settings/ISetting.cpp new file mode 100644 index 0000000000000..8f4f4fce364d5 --- /dev/null +++ b/xbmc/settings/ISetting.cpp @@ -0,0 +1,69 @@ +/* + * 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 + * . + * + */ + +#include "ISetting.h" +#include "utils/log.h" +#include "utils/XBMCTinyXML.h" + +#define XML_VISIBLE "visible" +#define XML_CONDITION "condition" + +using namespace std; + +ISetting::ISetting(const std::string &id, CSettingsManager *settingsManager /* = NULL */) + : m_id(id), + m_settingsManager(settingsManager), + m_visible(true), + m_visibilityCondition(settingsManager) +{ } + +bool ISetting::Deserialize(const TiXmlNode *node, bool update /* = false */) +{ + if (node == NULL) + return false; + + const TiXmlNode *visibleNode = node->FirstChild(XML_VISIBLE); + if (visibleNode == NULL) + return true; + + return m_visibilityCondition.Deserialize(visibleNode); +} + +bool ISetting::DeserializeIdentification(const TiXmlNode *node, std::string &identification) +{ + if (node == NULL) + return false; + + const TiXmlElement *element = node->ToElement(); + if (element == NULL) + return false; + + const char *idAttribute = element->Attribute(XML_ATTR_ID); + if (idAttribute == NULL || strlen(idAttribute) <= 0) + return false; + + identification = idAttribute; + return true; +} + +void ISetting::CheckVisible() +{ + m_visible = m_visibilityCondition.Check(); +} diff --git a/xbmc/settings/ISetting.h b/xbmc/settings/ISetting.h new file mode 100644 index 0000000000000..1b9429c3d849e --- /dev/null +++ b/xbmc/settings/ISetting.h @@ -0,0 +1,58 @@ +#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 + * . + * + */ +#include +#include + +#include "SettingVisibility.h" + +#define XML_SETTING "setting" + +#define XML_ATTR_ID "id" +#define XML_ATTR_LABEL "label" +#define XML_ATTR_HELP "help" +#define XML_ATTR_TYPE "type" + +class CSettingsManager; +class TiXmlNode; + +class ISetting +{ +public: + ISetting(const std::string &id, CSettingsManager *settingsManager = NULL); + virtual ~ISetting() { } + + virtual bool Deserialize(const TiXmlNode *node, bool update = false); + + const std::string& GetId() const { return m_id; } + bool IsVisible() const { return m_visible; } + void CheckVisible(); + void SetVisible(bool visible) { m_visible = visible; } + + static bool DeserializeIdentification(const TiXmlNode *node, std::string &identification); + +protected: + std::string m_id; + CSettingsManager *m_settingsManager; + +private: + bool m_visible; + CSettingVisibility m_visibilityCondition; +}; diff --git a/xbmc/settings/ISettingCallback.h b/xbmc/settings/ISettingCallback.h new file mode 100644 index 0000000000000..e665e97d45599 --- /dev/null +++ b/xbmc/settings/ISettingCallback.h @@ -0,0 +1,77 @@ +#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 + * . + * + */ + +class CSetting; +class TiXmlNode; + +class ISettingCallback +{ +public: + virtual ~ISettingCallback() { } + + /*! + \brief The value of the given setting is being changed. + + This callback is triggered whenever the value of a setting is being + changed. The given CSetting already contains the new value and + the handler of the callback has the possibility to allow or revert + changing the value of the setting. In case of a revert OnSettingChanging() + is called again to inform all listeners that the value change has been + reverted. + + \param setting The setting whose value is being changed (already containing the changed value) + \return True if the new value is acceptable otherwise false + */ + virtual bool OnSettingChanging(const CSetting *setting) { return true; } + + /*! + \brief The value of the given setting has changed. + + This callback is triggered whenever the value of a setting has been + successfully changed (i.e. none of the OnSettingChanging() handlers) + has reverted the change. + + \param setting The setting whose value has been changed + */ + virtual void OnSettingChanged(const CSetting *setting) { } + + /*! + \brief The given setting has been activated. + + This callback is triggered whenever the given setting has been + activated. This callback is only fired for CSettingAction settings. + + \param setting The setting which has been activated. + */ + virtual void OnSettingAction(const CSetting *setting) { } + + /*! + \brief The given setting needs to be updated. + + This callback is triggered when a setting needs to be updated + because its value is outdated. This only happens when initially + loading the value of a setting and will not be triggered afterwards. + + \param setting The setting which needs to be updated. + \return True if the setting has been successfully updated otherwise false + */ + virtual bool OnSettingUpdate(CSetting* &setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) { return false; } +}; diff --git a/xbmc/settings/ISettingCreator.h b/xbmc/settings/ISettingCreator.h new file mode 100644 index 0000000000000..0ddd79f913e61 --- /dev/null +++ b/xbmc/settings/ISettingCreator.h @@ -0,0 +1,33 @@ +#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 + * . + * + */ + +#include + +class CSetting; +class CSettingsManager; + +class ISettingCreator +{ +public: + virtual ~ISettingCreator() { } + + virtual CSetting* CreateSetting(const std::string &settingType, const std::string &settingId, CSettingsManager *settingsManager = NULL) const = 0; +}; diff --git a/xbmc/settings/ISubSettings.h b/xbmc/settings/ISubSettings.h index 3f3b3166468c1..005972d155f7c 100644 --- a/xbmc/settings/ISubSettings.h +++ b/xbmc/settings/ISubSettings.h @@ -44,4 +44,4 @@ class ISubSettings \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 118e431e7ace4..33a08a1a09e0d 100644 --- a/xbmc/settings/Makefile +++ b/xbmc/settings/Makefile @@ -1,9 +1,20 @@ SRCS=AdvancedSettings.cpp \ DisplaySettings.cpp \ - GUISettings.cpp \ + ISetting.cpp \ MediaSettings.cpp \ MediaSourceSettings.cpp \ + Setting.cpp \ + SettingAddon.cpp \ + SettingCategoryAccess.cpp \ + SettingConditions.cpp \ + SettingControl.cpp \ + SettingDependency.cpp \ + SettingPath.cpp \ + SettingSection.cpp \ Settings.cpp \ + SettingsManager.cpp \ + SettingUpdate.cpp \ + SettingVisibility.cpp \ SkinSettings.cpp \ VideoSettings.cpp \ diff --git a/xbmc/settings/MediaSettings.cpp b/xbmc/settings/MediaSettings.cpp index ee48085cf7461..484644c7bdc02 100644 --- a/xbmc/settings/MediaSettings.cpp +++ b/xbmc/settings/MediaSettings.cpp @@ -21,10 +21,23 @@ #include #include "MediaSettings.h" +#include "Application.h" +#include "Util.h" +#include "dialogs/GUIDialogContextMenu.h" +#include "dialogs/GUIDialogFileBrowser.h" +#include "dialogs/GUIDialogYesNo.h" +#include "guilib/WindowIDs.h" +#include "interfaces/Builtins.h" +#include "music/MusicDatabase.h" +#include "profiles/ProfilesManager.h" +#include "settings/Setting.h" +#include "storage/MediaManager.h" #include "threads/SingleLock.h" #include "utils/log.h" +#include "utils/URIUtils.h" #include "utils/XBMCTinyXML.h" #include "utils/XMLUtils.h" +#include "video/VideoDatabase.h" using namespace std; @@ -237,6 +250,99 @@ bool CMediaSettings::Save(TiXmlNode *settings) const return true; } +void CMediaSettings::OnSettingAction(const CSetting *setting) +{ + if (setting == NULL) + return; + + const std::string &settingId = setting->GetId(); + if (settingId == "karaoke.export") + { + CContextButtons choices; + choices.Add(1, g_localizeStrings.Get(22034)); + choices.Add(2, g_localizeStrings.Get(22035)); + + int retVal = CGUIDialogContextMenu::ShowAndGetChoice(choices); + if ( retVal > 0 ) + { + CStdString path(CProfilesManager::Get().GetDatabaseFolder()); + VECSOURCES shares; + g_mediaManager.GetLocalDrives(shares); + if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares, g_localizeStrings.Get(661), path, true)) + { + CMusicDatabase musicdatabase; + musicdatabase.Open(); + + if ( retVal == 1 ) + { + URIUtils::AddFileToFolder(path, "karaoke.html", path); + musicdatabase.ExportKaraokeInfo( path, true ); + } + else + { + URIUtils::AddFileToFolder(path, "karaoke.csv", path); + musicdatabase.ExportKaraokeInfo( path, false ); + } + musicdatabase.Close(); + } + } + } + else if (settingId == "karaoke.importcsv") + { + CStdString path(CProfilesManager::Get().GetDatabaseFolder()); + VECSOURCES shares; + g_mediaManager.GetLocalDrives(shares); + if (CGUIDialogFileBrowser::ShowAndGetFile(shares, "karaoke.csv", g_localizeStrings.Get(651) , path)) + { + CMusicDatabase musicdatabase; + musicdatabase.Open(); + musicdatabase.ImportKaraokeInfo(path); + musicdatabase.Close(); + } + } + else if (settingId == "musiclibrary.cleanup") + { + CMusicDatabase musicdatabase; + musicdatabase.Clean(); + CUtil::DeleteMusicDatabaseDirectoryCache(); + } + else if (settingId == "musiclibrary.export") + CBuiltins::Execute("exportlibrary(music)"); + else if (settingId == "musiclibrary.import") + { + CStdString path; + VECSOURCES shares; + g_mediaManager.GetLocalDrives(shares); + if (CGUIDialogFileBrowser::ShowAndGetFile(shares, "musicdb.xml", g_localizeStrings.Get(651) , path)) + { + CMusicDatabase musicdatabase; + musicdatabase.Open(); + musicdatabase.ImportFromXML(path); + musicdatabase.Close(); + } + } + else if (settingId == "videolibrary.cleanup") + { + if (CGUIDialogYesNo::ShowAndGetInput(313, 333, 0, 0)) + g_application.StartVideoCleanup(); + } + else if (settingId == "videolibrary.export") + CBuiltins::Execute("exportlibrary(video)"); + else if (settingId == "videolibrary.import") + { + CStdString path; + VECSOURCES shares; + g_mediaManager.GetLocalDrives(shares); + if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares, g_localizeStrings.Get(651) , path)) + { + CVideoDatabase videodatabase; + videodatabase.Open(); + videodatabase.ImportFromXML(path); + videodatabase.Close(); + } + } +} + int CMediaSettings::GetWatchedMode(const std::string &content) const { CSingleLock lock(m_critical); diff --git a/xbmc/settings/MediaSettings.h b/xbmc/settings/MediaSettings.h index 9747a2567baf2..b2dad89a7f95b 100644 --- a/xbmc/settings/MediaSettings.h +++ b/xbmc/settings/MediaSettings.h @@ -22,6 +22,7 @@ #include #include +#include "settings/ISettingCallback.h" #include "settings/ISubSettings.h" #include "settings/VideoSettings.h" #include "threads/CriticalSection.h" @@ -37,7 +38,7 @@ typedef enum { WatchedModeWatched } WatchedMode; -class CMediaSettings : public ISubSettings +class CMediaSettings : public ISettingCallback, public ISubSettings { public: static CMediaSettings& Get(); @@ -45,6 +46,8 @@ class CMediaSettings : public ISubSettings virtual bool Load(const TiXmlNode *settings); virtual bool Save(TiXmlNode *settings) const; + virtual void OnSettingAction(const CSetting *setting); + const CVideoSettings& GetDefaultVideoSettings() const { return m_defaultVideoSettings; } CVideoSettings& GetDefaultVideoSettings() { return m_defaultVideoSettings; } const CVideoSettings& GetCurrentVideoSettings() const { return m_currentVideoSettings; } diff --git a/xbmc/settings/Setting.cpp b/xbmc/settings/Setting.cpp new file mode 100644 index 0000000000000..dc8bb651694e2 --- /dev/null +++ b/xbmc/settings/Setting.cpp @@ -0,0 +1,913 @@ +/* + * 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 + * . + * + */ + +#include + +#include "Setting.h" +#include "threads/SingleLock.h" +#include "utils/log.h" +#include "utils/StringUtils.h" +#include "utils/XBMCTinyXML.h" +#include "utils/XMLUtils.h" + +#define XML_ELM_LEVEL "level" +#define XML_ELM_DEFAULT "default" +#define XML_ELM_VALUE "value" + +#define XML_ELM_CONSTRAINTS "constraints" +#define XML_ELM_OPTIONS "options" +#define XML_ELM_MINIMUM "minimum" +#define XML_ELM_STEP "step" +#define XML_ELM_MAXIMUM "maximum" + +CSetting::CSetting(const std::string &id, CSettingsManager *settingsManager /* = NULL */) + : ISetting(id, settingsManager), + m_callback(NULL), + m_label(-1), m_help(-1), + m_level(SettingLevelStandard), + m_changed(false) +{ } + +CSetting::CSetting(const std::string &id, const CSetting &setting) + : ISetting(id, setting.m_settingsManager), + m_callback(NULL), + m_label(-1), m_help(-1), + m_level(SettingLevelStandard), + m_changed(false) +{ + m_id = id; + Copy(setting); +} + +bool CSetting::Deserialize(const TiXmlNode *node, bool update /* = false */) +{ + // handle conditions + if (!ISetting::Deserialize(node, update)) + return false; + + const TiXmlElement *element = node->ToElement(); + if (element == NULL) + return false; + + // get the attributes label and help + int tmp = -1; + if (element->QueryIntAttribute(XML_ATTR_LABEL, &m_label) == TIXML_SUCCESS && tmp > 0) + m_label = tmp; + if (element->QueryIntAttribute(XML_ATTR_HELP, &m_help) == TIXML_SUCCESS && tmp > 0) + m_help = tmp; + + // get the + int level = -1; + if (XMLUtils::GetInt(node, XML_ELM_LEVEL, level)) + m_level = (SettingLevel)level; + + if (m_level < (int)SettingLevelBasic || m_level > (int)SettingLevelInternal) + m_level = SettingLevelStandard; + + const TiXmlElement *control = node->FirstChildElement("control"); + if (control != NULL) + { + if (!m_control.Deserialize(control, update) || + m_control.GetType() == SettingControlTypeNone) + { + CLog::Log(LOGERROR, "CSetting: error reading tag of \"%s\"", m_id.c_str()); + return false; + } + + const TiXmlNode *dependencies = control->FirstChild("dependencies"); + if (dependencies != NULL) + { + const TiXmlNode *dependencyNode = dependencies->FirstChild("dependency"); + while (dependencyNode != NULL) + { + CSettingDependency dependency(m_settingsManager); + if (dependency.Deserialize(dependencyNode)) + m_dependencies.push_back(dependency); + else + CLog::Log(LOGWARNING, "CSetting: error reading tag of \"%s\"", m_id.c_str()); + + dependencyNode = dependencyNode->NextSibling("dependency"); + } + } + } + + const TiXmlNode *updates = node->FirstChild("updates"); + if (updates != NULL) + { + const TiXmlElement *updateElem = updates->FirstChildElement("update"); + while (updateElem != NULL) + { + CSettingUpdate update; + if (update.Deserialize(updateElem)) + { + if (!m_updates.insert(update).second) + CLog::Log(LOGWARNING, "CSetting: duplicate definition for \"%s\"", m_id.c_str()); + } + else + CLog::Log(LOGWARNING, "CSetting: error reading tag of \"%s\"", m_id.c_str()); + + updateElem = updateElem->NextSiblingElement("update"); + } + } + + if ((m_control.GetType() == SettingControlTypeSpinner || m_control.GetType() == SettingControlTypeEdit) && + m_control.GetFormat() == SettingControlFormatNone) + { + CLog::Log(LOGERROR, "CSetting: invalid tag of \"%s\"", m_id.c_str()); + return false; + } + + return true; +} + +bool CSetting::OnSettingChanging(const CSetting *setting) +{ + if (m_callback == NULL) + return true; + + return m_callback->OnSettingChanging(setting); +} + +void CSetting::OnSettingChanged(const CSetting *setting) +{ + if (m_callback == NULL) + return; + + m_callback->OnSettingChanged(setting); +} + +void CSetting::OnSettingAction(const CSetting *setting) +{ + if (m_callback == NULL) + return; + + m_callback->OnSettingAction(setting); +} + +bool CSetting::OnSettingUpdate(CSetting* &setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) +{ + if (m_callback == NULL) + return false; + + return m_callback->OnSettingUpdate(setting, oldSettingId, oldSettingNode); +} + +void CSetting::Copy(const CSetting &setting) +{ + SetVisible(setting.IsVisible()); + m_callback = setting.m_callback; + m_label = setting.m_label; + m_help = setting.m_help; + m_level = setting.m_level; + m_control = setting.m_control; + m_dependencies = setting.m_dependencies; + m_updates = setting.m_updates; + m_changed = setting.m_changed; +} + +CSettingBool::CSettingBool(const std::string &id, CSettingsManager *settingsManager /* = NULL */) + : CSetting(id, settingsManager), + m_value(false), m_default(false) +{ + m_control.SetType(SettingControlTypeCheckmark); + m_control.SetFormat(SettingControlFormatBoolean); + m_control.SetAttributes(SettingControlAttributeNone); +} + +CSettingBool::CSettingBool(const std::string &id, const CSettingBool &setting) + : CSetting(id, setting) +{ + copy(setting); +} + +CSettingBool::CSettingBool(const std::string &id, int label, bool value, CSettingsManager *settingsManager /* = NULL */) + : CSetting(id, settingsManager), + m_value(value), m_default(value) +{ + m_label = label; + + m_control.SetType(SettingControlTypeCheckmark); + m_control.SetFormat(SettingControlFormatBoolean); + m_control.SetAttributes(SettingControlAttributeNone); +} + +bool CSettingBool::Deserialize(const TiXmlNode *node, bool update /* = false */) +{ + CSingleLock lock(m_critical); + + if (!CSetting::Deserialize(node, update)) + return false; + + if (m_control.GetType() != SettingControlTypeCheckmark || + m_control.GetFormat() != SettingControlFormatBoolean || + m_control.GetAttributes() != SettingControlAttributeNone) + { + CLog::Log(LOGERROR, "CSettingBool: invalid of \"%s\"", m_id.c_str()); + return false; + } + + // get the default value + bool value; + if (XMLUtils::GetBoolean(node, XML_ELM_DEFAULT, value)) + m_value = m_default = value; + else if (!update) + { + CLog::Log(LOGERROR, "CSettingBool: error reading the default value of \"%s\"", m_id.c_str()); + return false; + } + + return true; +} + +bool CSettingBool::FromString(const std::string &value) +{ + bool bValue; + if (!fromString(value, bValue)) + return false; + + return SetValue(bValue); +} + +std::string CSettingBool::ToString() const +{ + return m_value ? "true" : "false"; +} + +bool CSettingBool::Equals(const std::string &value) const +{ + bool bValue; + return (fromString(value, bValue) && m_value == bValue); +} + +bool CSettingBool::CheckValidity(const std::string &value) const +{ + bool bValue; + return fromString(value, bValue); +} + +bool CSettingBool::SetValue(bool value) +{ + CSingleLock lock(m_critical); + + if (value == m_value) + return true; + + bool oldValue = m_value; + m_value = value; + + if (!OnSettingChanging(this)) + { + m_value = oldValue; + + // the setting couldn't be changed because one of the + // callback handlers failed the OnSettingChanging() + // callback so we need to let all the callback handlers + // know that the setting hasn't changed + OnSettingChanging(this); + return false; + } + + m_changed = m_value != m_default; + OnSettingChanged(this); + return true; +} + +void CSettingBool::SetDefault(bool value) +{ + CSingleLock lock(m_critical); + + m_default = value; + if (!m_changed) + m_value = m_default; +} + +void CSettingBool::copy(const CSettingBool &setting) +{ + CSetting::Copy(setting); + + m_value = setting.m_value; + m_default = setting.m_default; +} + +bool CSettingBool::fromString(const std::string &strValue, bool &value) const +{ + CSingleLock lock(m_critical); + + if (StringUtils::EqualsNoCase(strValue, "true")) + { + value = true; + return true; + } + if (StringUtils::EqualsNoCase(strValue, "false")) + { + value = false; + return true; + } + + return false; +} + +CSettingInt::CSettingInt(const std::string &id, CSettingsManager *settingsManager /* = NULL */) + : CSetting(id, settingsManager), + m_value(0), m_default(0), + m_min(0), m_step(1), m_max(0), + m_format(-1), m_labelMin(-1), m_strFormat("%i") +{ } + +CSettingInt::CSettingInt(const std::string &id, const CSettingInt &setting) + : CSetting(id, setting) +{ + copy(setting); +} + +CSettingInt::CSettingInt(const std::string &id, int label, int value, int minimum, int step, int maximum, int format, int minimumLabel, CSettingsManager *settingsManager /* = NULL */) + : CSetting(id, settingsManager), + m_value(value), m_default(value), + m_min(minimum), m_step(step), m_max(maximum), + m_format(format), m_labelMin(minimumLabel), m_strFormat("%i") +{ + m_label = label; + + m_control.SetType(SettingControlTypeSpinner); + if (format < 0) + m_control.SetFormat(SettingControlFormatInteger); + else + m_control.SetFormat(SettingControlFormatString); + m_control.SetAttributes(SettingControlAttributeNone); +} + +CSettingInt::CSettingInt(const std::string &id, int label, int value, int minimum, int step, int maximum, const std::string &format, CSettingsManager *settingsManager /* = NULL */) + : CSetting(id, settingsManager), + m_value(value), m_default(value), + m_min(minimum), m_step(step), m_max(maximum), + m_format(-1), m_labelMin(-1), m_strFormat(format) +{ + m_label = label; + + m_control.SetType(SettingControlTypeSpinner); + if (format.empty()) + { + m_strFormat = "%i"; + m_control.SetFormat(SettingControlFormatInteger); + } + else + m_control.SetFormat(SettingControlFormatString); + m_control.SetAttributes(SettingControlAttributeNone); +} + +CSettingInt::CSettingInt(const std::string &id, int label, int value, const SettingOptions &options, CSettingsManager *settingsManager /* = NULL */) + : CSetting(id, settingsManager), + m_value(value), m_default(value), + m_min(0), m_step(1), m_max(0), + m_format(-1), m_labelMin(-1), m_strFormat("%i"), + m_options(options) +{ + m_label = label; + + m_control.SetType(SettingControlTypeSpinner); + m_control.SetFormat(SettingControlFormatString); + m_control.SetAttributes(SettingControlAttributeNone); +} + +bool CSettingInt::Deserialize(const TiXmlNode *node, bool update /* = false */) +{ + CSingleLock lock(m_critical); + + if (!CSetting::Deserialize(node, update)) + return false; + + if (m_control.GetType() == SettingControlTypeCheckmark) + { + CLog::Log(LOGERROR, "CSettingInt: invalid of \"%s\"", m_id.c_str()); + return false; + } + + // get the default value + int value; + if (XMLUtils::GetInt(node, XML_ELM_DEFAULT, value)) + m_value = m_default = value; + else if (!update) + { + CLog::Log(LOGERROR, "CSettingInt: error reading the default value of \"%s\"", m_id.c_str()); + return false; + } + + const TiXmlNode *constraints = node->FirstChild(XML_ELM_CONSTRAINTS); + if (constraints != NULL) + { + // get the entries + const TiXmlNode *options = constraints->FirstChild(XML_ELM_OPTIONS); + if (options != NULL && options->FirstChild() != NULL) + { + if (options->FirstChild()->Type() == TiXmlNode::TINYXML_TEXT) + m_optionsFiller = options->FirstChild()->ValueStr(); + else + { + m_options.clear(); + const TiXmlElement *optionElement = options->FirstChildElement("option"); + while (optionElement != NULL) + { + std::pair entry; + if (optionElement->QueryIntAttribute("label", &entry.first) == TIXML_SUCCESS && entry.first > 0) + { + entry.second = strtol(optionElement->FirstChild()->Value(), NULL, 10); + m_options.push_back(entry); + } + + optionElement = optionElement->NextSiblingElement("option"); + } + } + } + + // get minimum + if (XMLUtils::GetInt(constraints, XML_ELM_MINIMUM, m_min) && + m_control.GetFormat() == SettingControlFormatString) + { + const TiXmlElement *minimumElement = constraints->FirstChildElement(XML_ELM_MINIMUM); + if (minimumElement->QueryIntAttribute(XML_ATTR_LABEL, &m_labelMin) != TIXML_SUCCESS) + m_labelMin = -1; + } + // get step + XMLUtils::GetInt(constraints, XML_ELM_STEP, m_step); + // get maximum + XMLUtils::GetInt(constraints, XML_ELM_MAXIMUM, m_max); + + if (m_control.GetFormat() == SettingControlFormatString) + { + XMLUtils::GetInt(constraints, "formatlabel", m_format); + + if (m_labelMin < 0) + { + CStdString strFormat; + if (XMLUtils::GetString(constraints, "format", strFormat) && !strFormat.empty()) + m_strFormat = strFormat; + } + } + } + + return true; +} + +bool CSettingInt::FromString(const std::string &value) +{ + int iValue; + if (!fromString(value, iValue)) + return false; + + return SetValue(iValue); +} + +std::string CSettingInt::ToString() const +{ + std::ostringstream oss; + oss << m_value; + + return oss.str(); +} + +bool CSettingInt::Equals(const std::string &value) const +{ + int iValue; + return (fromString(value, iValue) && m_value == iValue); +} + +bool CSettingInt::CheckValidity(const std::string &value) const +{ + int iValue; + if (!fromString(value, iValue)) + return false; + + return CheckValidity(iValue); +} + +bool CSettingInt::CheckValidity(int value) const +{ + if (!m_options.empty()) + { + //if the setting is an std::map, check if we got a valid value before assigning it + bool ok = false; + for (SettingOptions::const_iterator it = m_options.begin(); it != m_options.end(); it++) + { + if (it->second == value) + { + ok = true; + break; + } + } + + if (!ok) + return false; + } + else if (m_optionsFiller.empty() && m_min != m_max && + (value < m_min || value > m_max)) + return false; + + return true; +} + +bool CSettingInt::SetValue(int value) +{ + CSingleLock lock(m_critical); + + if (value == m_value) + return true; + + if (!CheckValidity(value)) + return false; + + int oldValue = m_value; + m_value = value; + + if (!OnSettingChanging(this)) + { + m_value = oldValue; + + // the setting couldn't be changed because one of the + // callback handlers failed the OnSettingChanging() + // callback so we need to let all the callback handlers + // know that the setting hasn't changed + OnSettingChanging(this); + return false; + } + + m_changed = m_value != m_default; + OnSettingChanged(this); + return true; +} + +void CSettingInt::SetDefault(int value) +{ + CSingleLock lock(m_critical); + + m_default = value; + if (!m_changed) + m_value = m_default; +} + +void CSettingInt::copy(const CSettingInt &setting) +{ + CSetting::Copy(setting); + + m_value = setting.m_value; + m_default = setting.m_default; + m_min = setting.m_min; + m_step = setting.m_step; + m_max = setting.m_max; + m_format = setting.m_format; + m_labelMin = setting.m_labelMin; + m_strFormat = setting.m_strFormat; + m_options = setting.m_options; + m_optionsFiller = setting.m_optionsFiller; +} + +bool CSettingInt::fromString(const std::string &strValue, int &value) const +{ + if (strValue.empty()) + return false; + + char *end = NULL; + value = (int)strtol(strValue.c_str(), &end, 10); + if (end != NULL && *end != '\0') + return false; + + return true; +} + +CSettingNumber::CSettingNumber(const std::string &id, CSettingsManager *settingsManager /* = NULL */) + : CSetting(id, settingsManager), + m_value(0.0), m_default(0.0), + m_min(0.0), m_step(1.0), m_max(0.0) +{ } + +CSettingNumber::CSettingNumber(const std::string &id, const CSettingNumber &setting) + : CSetting(id, setting) +{ + copy(setting); +} + +CSettingNumber::CSettingNumber(const std::string &id, int label, float value, float minimum, float step, float maximum, CSettingsManager *settingsManager /* = NULL */) + : CSetting(id, settingsManager), + m_value(value), m_default(value), + m_min(minimum), m_step(step), m_max(maximum) +{ + m_label = label; + + m_control.SetType(SettingControlTypeSpinner); + m_control.SetFormat(SettingControlFormatNumber); + m_control.SetAttributes(SettingControlAttributeNone); +} + +bool CSettingNumber::Deserialize(const TiXmlNode *node, bool update /* = false */) +{ + CSingleLock lock(m_critical); + + if (!CSetting::Deserialize(node, update)) + return false; + + if (m_control.GetType() == SettingControlTypeCheckmark) + { + CLog::Log(LOGERROR, "CSettingInt: invalid of \"%s\"", m_id.c_str()); + return false; + } + + // get the default value + double value; + if (XMLUtils::GetDouble(node, XML_ELM_DEFAULT, value)) + m_value = m_default = value; + else if (!update) + { + CLog::Log(LOGERROR, "CSettingNumber: error reading the default value of \"%s\"", m_id.c_str()); + return false; + } + + const TiXmlNode *constraints = node->FirstChild(XML_ELM_CONSTRAINTS); + if (constraints != NULL) + { + // get the minimum value + XMLUtils::GetDouble(constraints, XML_ELM_MINIMUM, m_min); + // get the step value + XMLUtils::GetDouble(constraints, XML_ELM_STEP, m_step); + // get the maximum value + XMLUtils::GetDouble(constraints, XML_ELM_MAXIMUM, m_max); + } + + return true; +} + +bool CSettingNumber::FromString(const std::string &value) +{ + double dValue; + if (!fromString(value, dValue)) + return false; + + return SetValue(dValue); +} + +std::string CSettingNumber::ToString() const +{ + std::ostringstream oss; + oss << m_value; + + return oss.str(); +} + +bool CSettingNumber::Equals(const std::string &value) const +{ + double dValue; + return (fromString(value, dValue) && m_value == dValue); +} + +bool CSettingNumber::CheckValidity(const std::string &value) const +{ + double dValue; + if (!fromString(value, dValue)) + return false; + + return CheckValidity(dValue); +} + +bool CSettingNumber::CheckValidity(double value) const +{ + if (m_min != m_max && + (value < m_min || value > m_max)) + return false; + + return true; +} + +bool CSettingNumber::SetValue(double value) +{ + CSingleLock lock(m_critical); + + if (value == m_value) + return true; + + if (!CheckValidity(value)) + return false; + + double oldValue = m_value; + m_value = value; + + if (!OnSettingChanging(this)) + { + m_value = oldValue; + + // the setting couldn't be changed because one of the + // callback handlers failed the OnSettingChanging() + // callback so we need to let all the callback handlers + // know that the setting hasn't changed + OnSettingChanging(this); + return false; + } + + m_changed = m_value != m_default; + OnSettingChanged(this); + return true; +} + +void CSettingNumber::SetDefault(double value) +{ + CSingleLock lock(m_critical); + + m_default = value; + if (!m_changed) + m_value = m_default; +} + +void CSettingNumber::copy(const CSettingNumber &setting) +{ + CSetting::Copy(setting); + + m_value = setting.m_value; + m_default = setting.m_default; + m_min = setting.m_min; + m_step = setting.m_step; + m_max = setting.m_max; +} + +bool CSettingNumber::fromString(const std::string &strValue, double &value) const +{ + if (strValue.empty()) + return false; + + char *end = NULL; + value = (int)strtod(strValue.c_str(), &end); + if (end != NULL && *end != '\0') + return false; + + return true; +} + +CSettingString::CSettingString(const std::string &id, CSettingsManager *settingsManager /* = NULL */) + : CSetting(id, settingsManager), + m_allowEmpty(false), m_heading(-1) +{ } + +CSettingString::CSettingString(const std::string &id, const CSettingString &setting) + : CSetting(id, setting) +{ + copy(setting); +} + +CSettingString::CSettingString(const std::string &id, int label, const std::string &value, CSettingsManager *settingsManager /* = NULL */) + : CSetting(id, settingsManager), + m_value(value), m_default(value), + m_allowEmpty(false), m_heading(-1) +{ + m_label = label; + + m_control.SetType(SettingControlTypeEdit); + m_control.SetFormat(SettingControlFormatString); + m_control.SetAttributes(SettingControlAttributeNone); +} + +bool CSettingString::Deserialize(const TiXmlNode *node, bool update /* = false */) +{ + CSingleLock lock(m_critical); + + if (!CSetting::Deserialize(node, update)) + return false; + + if (m_control.GetType() == SettingControlTypeCheckmark || + (m_control.GetType() == SettingControlTypeSpinner && (m_control.GetFormat() == SettingControlFormatInteger || m_control.GetFormat() == SettingControlFormatNumber)) || + (m_control.GetType() == SettingControlTypeEdit && m_control.GetFormat() == SettingControlFormatNumber)) + { + CLog::Log(LOGERROR, "CSettingString: invalid of \"%s\"", m_id.c_str()); + return false; + } + + // get allowempty (needs to be parsed before parsing the default value) + XMLUtils::GetBoolean(node, "allowempty", m_allowEmpty); + // get heading + XMLUtils::GetInt(node, "heading", m_heading); + + // get the default value + CStdString value; + if (XMLUtils::GetString(node, XML_ELM_DEFAULT, value)) + m_value = m_default = value; + else if (!update && !m_allowEmpty) + { + CLog::Log(LOGERROR, "CSettingString: error reading the default value of \"%s\"", m_id.c_str()); + return false; + } + + const TiXmlNode *constraints = node->FirstChild(XML_ELM_CONSTRAINTS); + if (constraints != NULL) + { + // get the entries + const TiXmlNode *options = constraints->FirstChild(XML_ELM_OPTIONS); + if (options != NULL && options->FirstChild() != NULL && + options->FirstChild()->Type() == TiXmlNode::TINYXML_TEXT) + m_optionsFiller = options->FirstChild()->ValueStr(); + } + + return true; +} + +bool CSettingString::CheckValidity(const std::string &value) const +{ + if (!m_allowEmpty && value.empty()) + return false; + + return true; +} + +bool CSettingString::SetValue(const std::string &value) +{ + CSingleLock lock(m_critical); + + if (value == m_value) + return true; + + if (!CheckValidity(value)) + return false; + + std::string oldValue = m_value; + m_value = value; + + if (!OnSettingChanging(this)) + { + m_value = oldValue; + + // the setting couldn't be changed because one of the + // callback handlers failed the OnSettingChanging() + // callback so we need to let all the callback handlers + // know that the setting hasn't changed + OnSettingChanging(this); + return false; + } + + m_changed = m_value != m_default; + OnSettingChanged(this); + return true; +} + +void CSettingString::SetDefault(const std::string &value) +{ + CSingleLock lock(m_critical); + + m_default = value; + if (!m_changed) + m_value = m_default; +} + +void CSettingString::copy(const CSettingString &setting) +{ + CSetting::Copy(setting); + + m_value = setting.m_value; + m_default = setting.m_default; + m_allowEmpty = setting.m_allowEmpty; + m_heading = setting.m_heading; +} + +CSettingAction::CSettingAction(const std::string &id, CSettingsManager *settingsManager /* = NULL */) + : CSetting(id, settingsManager) +{ + m_control.SetType(SettingControlTypeButton); + m_control.SetFormat(SettingControlFormatAction); + m_control.SetAttributes(SettingControlAttributeNone); +} + +CSettingAction::CSettingAction(const std::string &id, const CSettingAction &setting) + : CSetting(id, setting) +{ + m_control.SetType(SettingControlTypeButton); + m_control.SetFormat(SettingControlFormatAction); + m_control.SetAttributes(SettingControlAttributeNone); +} + +bool CSettingAction::Deserialize(const TiXmlNode *node, bool update /* = false */) +{ + CSingleLock lock(m_critical); + + if (!CSetting::Deserialize(node, update)) + return false; + + if (m_control.GetType() != SettingControlTypeButton || + m_control.GetFormat() != SettingControlFormatAction || + m_control.GetAttributes() != SettingControlAttributeNone) + { + CLog::Log(LOGERROR, "CSettingAction: invalid of \"%s\"", m_id.c_str()); + return false; + } + + return true; +} diff --git a/xbmc/settings/Setting.h b/xbmc/settings/Setting.h new file mode 100644 index 0000000000000..c686f84d61419 --- /dev/null +++ b/xbmc/settings/Setting.h @@ -0,0 +1,276 @@ +#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 + * . + * + */ + +#include +#include +#include +#include + +#include "ISetting.h" +#include "ISettingCallback.h" +#include "SettingControl.h" +#include "SettingDependency.h" +#include "SettingUpdate.h" +#include "threads/CriticalSection.h" + +typedef enum { + SettingTypeNone = 0, + SettingTypeBool, + SettingTypeInteger, + SettingTypeNumber, + SettingTypeString, + SettingTypeAction +} SettingType; + +typedef enum { + SettingLevelBasic = 0, + SettingLevelStandard, + SettingLevelAdvanced, + SettingLevelExpert, + SettingLevelInternal +} SettingLevel; + +typedef std::pair SettingOption; +typedef std::vector SettingOptions; + +class CSetting : public ISetting, + protected ISettingCallback +{ +public: + CSetting(const std::string &id, CSettingsManager *settingsManager = NULL); + CSetting(const std::string &id, const CSetting &setting); + virtual ~CSetting() { } + + virtual bool Deserialize(const TiXmlNode *node, bool update = false); + + virtual int GetType() const = 0; + virtual bool FromString(const std::string &value) = 0; + virtual std::string ToString() const = 0; + virtual bool Equals(const std::string &value) const = 0; + virtual bool CheckValidity(const std::string &value) const = 0; + virtual void Reset() = 0; + + int GetLabel() const { return m_label; } + int GetHelp() const { return m_help; } + SettingLevel GetLevel() const { return m_level; } + const CSettingControl& GetControl() const { return m_control; } + const SettingDependencies& GetDependencies() const { return m_dependencies; } + const std::set& GetUpdates() const { return m_updates; } + +protected: + friend class CSettingsManager; + + virtual bool OnSettingChanging(const CSetting *setting); + virtual void OnSettingChanged(const CSetting *setting); + virtual void OnSettingAction(const CSetting *setting); + virtual bool OnSettingUpdate(CSetting* &setting, const char *oldSettingId, const TiXmlNode *oldSettingNode); + + void Copy(const CSetting &setting); + + ISettingCallback *m_callback; + int m_label; + int m_help; + SettingLevel m_level; + CSettingControl m_control; + SettingDependencies m_dependencies; + std::set m_updates; + bool m_changed; + CCriticalSection m_critical; +}; + +typedef std::vector SettingList; + +class CSettingBool : public CSetting +{ +public: + CSettingBool(const std::string &id, CSettingsManager *settingsManager = NULL); + CSettingBool(const std::string &id, const CSettingBool &setting); + CSettingBool(const std::string &id, int label, bool value, CSettingsManager *settingsManager = NULL); + virtual ~CSettingBool() { } + + virtual bool Deserialize(const TiXmlNode *node, bool update = false); + + virtual int GetType() const { return SettingTypeBool; } + virtual bool FromString(const std::string &value); + virtual std::string ToString() const; + virtual bool Equals(const std::string &value) const; + virtual bool CheckValidity(const std::string &value) const; + virtual void Reset() { SetValue(m_default); } + + bool GetValue() const { return m_value; } + bool SetValue(bool value); + bool GetDefault() const { return m_default; } + void SetDefault(bool value); + +private: + void copy(const CSettingBool &setting); + bool fromString(const std::string &strValue, bool &value) const; + + bool m_value; + bool m_default; +}; + +class CSettingInt : public CSetting +{ +public: + CSettingInt(const std::string &id, CSettingsManager *settingsManager = NULL); + CSettingInt(const std::string &id, const CSettingInt &setting); + CSettingInt(const std::string &id, int label, int value, int minimum, int step, int maximum, int format, int minimumLabel, CSettingsManager *settingsManager = NULL); + CSettingInt(const std::string &id, int label, int value, int minimum, int step, int maximum, const std::string &format, CSettingsManager *settingsManager = NULL); + CSettingInt(const std::string &id, int label, int value, const SettingOptions &options, CSettingsManager *settingsManager = NULL); + virtual ~CSettingInt() { } + + virtual bool Deserialize(const TiXmlNode *node, bool update = false); + + virtual int GetType() const { return SettingTypeInteger; } + virtual bool FromString(const std::string &value); + virtual std::string ToString() const; + virtual bool Equals(const std::string &value) const; + virtual bool CheckValidity(const std::string &value) const; + virtual bool CheckValidity(int value) const; + virtual void Reset() { SetValue(m_default); } + + int GetValue() const { return m_value; } + bool SetValue(int value); + int GetDefault() const { return m_default; } + void SetDefault(int value); + + int GetMinimum() const { return m_min; } + int GetStep() const { return m_step; } + int GetMaximum() const { return m_max; } + + int GetFormat() const { return m_format; } + int GetMinimumLabel() const { return m_labelMin; } + const std::string& GetFormatString() const { return m_strFormat; } + const SettingOptions& GetOptions() const { return m_options; } + const std::string& GetOptionsFiller() const { return m_optionsFiller; } + +private: + void copy(const CSettingInt &setting); + bool fromString(const std::string &strValue, int &value) const; + + int m_value; + int m_default; + int m_min; + int m_step; + int m_max; + int m_format; + int m_labelMin; + std::string m_strFormat; + SettingOptions m_options; + std::string m_optionsFiller; +}; + +class CSettingNumber : public CSetting +{ +public: + CSettingNumber(const std::string &id, CSettingsManager *settingsManager = NULL); + CSettingNumber(const std::string &id, const CSettingNumber &setting); + CSettingNumber(const std::string &id, int label, float value, float minimum, float step, float maximum, CSettingsManager *settingsManager = NULL); + virtual ~CSettingNumber() { } + + virtual bool Deserialize(const TiXmlNode *node, bool update = false); + + virtual int GetType() const { return SettingTypeNumber; } + virtual bool FromString(const std::string &value); + virtual std::string ToString() const; + virtual bool Equals(const std::string &value) const; + virtual bool CheckValidity(const std::string &value) const; + virtual bool CheckValidity(double value) const; + virtual void Reset() { SetValue(m_default); } + + double GetValue() const { return m_value; } + bool SetValue(double value); + double GetDefault() const { return m_default; } + void SetDefault(double value); + + double GetMinimum() const { return m_min; } + double GetStep() const { return m_step; } + double GetMaximum() const { return m_max; } + +private: + virtual void copy(const CSettingNumber &setting); + bool fromString(const std::string &strValue, double &value) const; + + double m_value; + double m_default; + double m_min; + double m_step; + double m_max; +}; + +class CSettingString : public CSetting +{ +public: + CSettingString(const std::string &id, CSettingsManager *settingsManager = NULL); + CSettingString(const std::string &id, const CSettingString &setting); + CSettingString(const std::string &id, int label, const std::string &value, CSettingsManager *settingsManager = NULL); + virtual ~CSettingString() { } + + virtual bool Deserialize(const TiXmlNode *node, bool update = false); + + virtual int GetType() const { return SettingTypeString; } + virtual bool FromString(const std::string &value) { return SetValue(value); } + virtual std::string ToString() const { return m_value; } + virtual bool Equals(const std::string &value) const { return m_value == value; } + virtual bool CheckValidity(const std::string &value) const; + virtual void Reset() { SetValue(m_default); } + + virtual const std::string& GetValue() const { return m_value; } + virtual bool SetValue(const std::string &value); + virtual const std::string& GetDefault() const { return m_default; } + virtual void SetDefault(const std::string &value); + + virtual bool AllowEmpty() const { return m_allowEmpty; } + virtual int GetHeading() const { return m_heading; } + + const std::string& GetOptionsFiller() const { return m_optionsFiller; } + +protected: + virtual void copy(const CSettingString &setting); + + std::string m_value; + std::string m_default; + bool m_allowEmpty; + int m_heading; + std::string m_optionsFiller; +}; + +class CSettingAction : public CSetting +{ +public: + CSettingAction(const std::string &id, CSettingsManager *settingsManager = NULL); + CSettingAction(const std::string &id, const CSettingAction &setting); + virtual ~CSettingAction() { } + + virtual bool Deserialize(const TiXmlNode *node, bool update = false); + + virtual int GetType() const { return SettingTypeAction; } + virtual bool FromString(const std::string &value) { return false; } + virtual std::string ToString() const { return ""; } + virtual bool Equals(const std::string &value) const { return false; } + virtual bool CheckValidity(const std::string &value) const { return false; } + virtual void Reset() { } + + // this needs to be public so it can be triggered when activated + // by the user in the GUI. + virtual void OnSettingAction(const CSetting *setting) { return CSetting::OnSettingAction(this); } +}; diff --git a/xbmc/settings/SettingAddon.cpp b/xbmc/settings/SettingAddon.cpp new file mode 100644 index 0000000000000..bcf6dd38d656a --- /dev/null +++ b/xbmc/settings/SettingAddon.cpp @@ -0,0 +1,96 @@ +/* + * 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 + * . + * + */ + +#include "SettingAddon.h" +#include "addons/Addon.h" +#include "settings/SettingsManager.h" +#include "threads/SingleLock.h" +#include "utils/log.h" +#include "utils/XBMCTinyXML.h" +#include "utils/XMLUtils.h" + +#define XML_ELM_DEFAULT "default" + +CSettingAddon::CSettingAddon(const std::string &id, CSettingsManager *settingsManager /* = NULL */) + : CSettingString(id, settingsManager), + m_addonType(ADDON::ADDON_UNKNOWN) +{ + m_control.SetType(SettingControlTypeButton); + m_control.SetFormat(SettingControlFormatAddon); + m_control.SetAttributes(SettingControlAttributeNone); +} + +CSettingAddon::CSettingAddon(const std::string &id, const CSettingAddon &setting) + : CSettingString(id, setting) +{ + copy(setting); +} + +bool CSettingAddon::Deserialize(const TiXmlNode *node, bool update /* = false */) +{ + CSingleLock lock(m_critical); + + if (!CSettingString::Deserialize(node, update)) + return false; + + if (m_control.GetType() != SettingControlTypeButton || + m_control.GetFormat() != SettingControlFormatAddon || + m_control.GetAttributes() != SettingControlAttributeNone) + { + CLog::Log(LOGERROR, "CSettingAddon: invalid of \"%s\"", m_id.c_str()); + return false; + } + + // get the default value by abusing the FromString + // implementation to parse the default value + CStdString value; + if (XMLUtils::GetString(node, XML_ELM_DEFAULT, value)) + m_value = m_default = value; + else if (!update) + { + CLog::Log(LOGERROR, "CSettingAddon: error reading the default value of \"%s\"", m_id.c_str()); + return false; + } + + // get the addon type + CStdString strAddonType; + bool ok = XMLUtils::GetString(node, "addontype", strAddonType); + if (ok) + { + m_addonType = ADDON::TranslateType(strAddonType); + if (m_addonType == ADDON::ADDON_UNKNOWN) + ok = false; + } + + if (!ok && !update) + { + CLog::Log(LOGERROR, "CSettingAddon: error reading the addontype value \"%s\" of \"%s\"", strAddonType.c_str(), m_id.c_str()); + return false; + } + + return true; +} + +void CSettingAddon::copy(const CSettingAddon &setting) +{ + CSettingString::Copy(setting); + + m_addonType = setting.m_addonType; +} diff --git a/xbmc/settings/SettingAddon.h b/xbmc/settings/SettingAddon.h new file mode 100644 index 0000000000000..644c325652d67 --- /dev/null +++ b/xbmc/settings/SettingAddon.h @@ -0,0 +1,40 @@ +#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 + * . + * + */ + +#include "Setting.h" +#include "addons/IAddon.h" + +class CSettingAddon : public CSettingString +{ +public: + CSettingAddon(const std::string &id, CSettingsManager *settingsManager = NULL); + CSettingAddon(const std::string &id, const CSettingAddon &setting); + virtual ~CSettingAddon() { } + + virtual bool Deserialize(const TiXmlNode *node, bool update = false); + + ADDON::TYPE GetAddonType() const { return m_addonType; } + +private: + void copy(const CSettingAddon &setting); + + ADDON::TYPE m_addonType; +}; diff --git a/xbmc/settings/SettingCategoryAccess.cpp b/xbmc/settings/SettingCategoryAccess.cpp new file mode 100644 index 0000000000000..609eb853dab6b --- /dev/null +++ b/xbmc/settings/SettingCategoryAccess.cpp @@ -0,0 +1,53 @@ +/* + * 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 + * . + * + */ + +#include "SettingCategoryAccess.h" +#include "SettingConditions.h" +#include "SettingsManager.h" +#include "utils/log.h" + +bool CSettingCategoryAccessCondition::Check() const +{ + if (m_value.empty()) + return true; + + if (m_settingsManager == NULL) + return false; + + bool found = m_settingsManager->GetConditions().Check(m_value, "true"); + if (m_negated) + return !found; + + return found; +} + +bool CSettingCategoryAccessConditionCombination::Check() const +{ + if (m_operations.empty() && m_values.empty()) + return true; + + return CSettingConditionCombination::Check(); +} + +CSettingCategoryAccess::CSettingCategoryAccess(CSettingsManager *settingsManager /* = NULL */) + : CSettingCondition(settingsManager) +{ + m_operation = CBooleanLogicOperationPtr(new CSettingCategoryAccessConditionCombination(m_settingsManager)); +} diff --git a/xbmc/settings/SettingCategoryAccess.h b/xbmc/settings/SettingCategoryAccess.h new file mode 100644 index 0000000000000..bc1cc3a173f0f --- /dev/null +++ b/xbmc/settings/SettingCategoryAccess.h @@ -0,0 +1,58 @@ +#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 + * . + * + */ + +#include +#include + +#include "SettingConditions.h" + +class CSettingCategoryAccessCondition : public CSettingConditionItem +{ +public: + CSettingCategoryAccessCondition(CSettingsManager *settingsManager = NULL) + : CSettingConditionItem(settingsManager) + { } + virtual ~CSettingCategoryAccessCondition() { } + + virtual bool Check() const; +}; + +class CSettingCategoryAccessConditionCombination : public CSettingConditionCombination +{ +public: + CSettingCategoryAccessConditionCombination(CSettingsManager *settingsManager = NULL) + : CSettingConditionCombination(settingsManager) + { } + virtual ~CSettingCategoryAccessConditionCombination() { } + + virtual bool Check() const; + +private: + virtual CBooleanLogicOperation* newOperation() { return new CSettingCategoryAccessConditionCombination(m_settingsManager); } + virtual CBooleanLogicValue* newValue() { return new CSettingCategoryAccessCondition(m_settingsManager); } +}; + +class CSettingCategoryAccess : public CSettingCondition +{ +public: + CSettingCategoryAccess(CSettingsManager *settingsManager = NULL); + virtual ~CSettingCategoryAccess() { } +}; diff --git a/xbmc/settings/SettingConditions.cpp b/xbmc/settings/SettingConditions.cpp new file mode 100644 index 0000000000000..d06aac99d91ef --- /dev/null +++ b/xbmc/settings/SettingConditions.cpp @@ -0,0 +1,156 @@ +/* + * 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 + * . + * + */ + +#include "SettingConditions.h" +#include "SettingsManager.h" +#include "utils/StringUtils.h" +#include "utils/XBMCTinyXML.h" + +bool CSettingConditionItem::Deserialize(const TiXmlNode *node) +{ + if (!CBooleanLogicValue::Deserialize(node)) + return false; + + const TiXmlElement *elem = node->ToElement(); + if (elem == NULL) + return false; + + // get the "name" attribute + const char *strAttribute = elem->Attribute("name"); + if (strAttribute != NULL) + m_name = strAttribute; + + // get the "setting" attribute + strAttribute = elem->Attribute("setting"); + if (strAttribute != NULL) + m_setting = strAttribute; + + return true; +} + +bool CSettingConditionItem::Check() const +{ + if (m_settingsManager == NULL) + return false; + + return m_settingsManager->GetConditions().Check(m_name, m_value, m_setting) == !m_negated; +} + +bool CSettingConditionCombination::Check() const +{ + bool ok = false; + for (CBooleanLogicOperations::const_iterator operation = m_operations.begin(); + operation != m_operations.end(); operation++) + { + if (*operation == NULL) + continue; + + CSettingConditionCombination *combination = static_cast((*operation).get()); + if (combination == NULL) + continue; + + if (combination->Check()) + ok = true; + else if (m_operation == BooleanLogicOperationAnd) + return false; + } + + for (CBooleanLogicValues::const_iterator value = m_values.begin(); + value != m_values.end(); value++) + { + if (*value == NULL) + continue; + + CSettingConditionItem *condition = static_cast((*value).get()); + if (condition == NULL) + continue; + + if (condition->Check()) + ok = true; + else if (m_operation == BooleanLogicOperationAnd) + return false; + } + + return ok; +} + +CSettingCondition::CSettingCondition(CSettingsManager *settingsManager /* = NULL */) + : ISettingCondition(settingsManager) +{ + m_operation = CBooleanLogicOperationPtr(new CSettingConditionCombination(settingsManager)); +} + +bool CSettingCondition::Check() const +{ + CSettingConditionCombination *combination = static_cast(m_operation.get()); + if (combination == NULL) + return false; + + return combination->Check(); +} + +void CSettingConditionsManager::AddCondition(const std::string &condition) +{ + if (condition.empty()) + return; + + m_defines.insert(condition); +} + +void CSettingConditionsManager::AddCondition(const std::string &identifier, SettingConditionCheck condition) +{ + if (identifier.empty() || condition == NULL) + return; + + m_conditions.insert(SettingConditionPair(identifier, condition)); +} + +bool CSettingConditionsManager::Check(const std::string &condition, const std::string &value /* = "" */, const std::string settingId /* = "" */) const +{ + if (condition.empty()) + return false; + + std::string tmpCondition = condition; + StringUtils::ToLower(tmpCondition); + + // special handling of "isdefined" conditions + if (tmpCondition == "isdefined") + { + std::string tmpValue = value; + StringUtils::ToLower(tmpValue); + + return m_defines.find(tmpValue) != m_defines.end(); + } + + SettingConditionMap::const_iterator conditionIt = m_conditions.find(tmpCondition); + if (conditionIt == m_conditions.end()) + return false; + + return conditionIt->second(tmpCondition, value, settingId); +} + +CSettingConditionsManager::CSettingConditionsManager() +{ } + +CSettingConditionsManager::~CSettingConditionsManager() +{ + m_conditions.clear(); + m_defines.clear(); +} diff --git a/xbmc/settings/SettingConditions.h b/xbmc/settings/SettingConditions.h new file mode 100644 index 0000000000000..4b2fe7726aa59 --- /dev/null +++ b/xbmc/settings/SettingConditions.h @@ -0,0 +1,107 @@ +#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 + * . + * + */ + +#include +#include +#include + +#include "utils/BooleanLogic.h" + +class CSettingsManager; + +typedef bool (*SettingConditionCheck)(const std::string &condition, const std::string &value, const std::string &settingId); + +class ISettingCondition +{ +public: + ISettingCondition(CSettingsManager *settingsManager) + : m_settingsManager(settingsManager) + { } + virtual ~ISettingCondition() { } + + virtual bool Check() const = 0; + +protected: + CSettingsManager *m_settingsManager; +}; + +class CSettingConditionItem : public CBooleanLogicValue, public ISettingCondition +{ +public: + CSettingConditionItem(CSettingsManager *settingsManager = NULL) + : ISettingCondition(settingsManager) + { } + virtual ~CSettingConditionItem() { } + + virtual bool Deserialize(const TiXmlNode *node); + virtual const char* GetTag() const { return "condition"; } + virtual bool Check() const; + +protected: + std::string m_name; + std::string m_setting; +}; + +class CSettingConditionCombination : public CBooleanLogicOperation, public ISettingCondition +{ +public: + CSettingConditionCombination(CSettingsManager *settingsManager = NULL) + : ISettingCondition(settingsManager) + { } + virtual ~CSettingConditionCombination() { } + + virtual bool Check() const; + +private: + virtual CBooleanLogicOperation* newOperation() { return new CSettingConditionCombination(m_settingsManager); } + virtual CBooleanLogicValue* newValue() { return new CSettingConditionItem(m_settingsManager); } +}; + +class CSettingCondition : public CBooleanLogic, public ISettingCondition +{ +public: + CSettingCondition(CSettingsManager *settingsManager = NULL); + virtual ~CSettingCondition() { } + + virtual bool Check() const; +}; + +class CSettingConditionsManager +{ +public: + CSettingConditionsManager(); + virtual ~CSettingConditionsManager(); + + void AddCondition(const std::string &condition); + void AddCondition(const std::string &identifier, SettingConditionCheck condition); + + bool Check(const std::string &condition, const std::string &value = "", const std::string settingId = "") const; + +private: + CSettingConditionsManager(const CSettingConditionsManager&); + CSettingConditionsManager const& operator=(CSettingConditionsManager const&); + + typedef std::pair SettingConditionPair; + typedef std::map SettingConditionMap; + + SettingConditionMap m_conditions; + std::set m_defines; +}; diff --git a/xbmc/settings/SettingControl.cpp b/xbmc/settings/SettingControl.cpp new file mode 100644 index 0000000000000..a8c6212566373 --- /dev/null +++ b/xbmc/settings/SettingControl.cpp @@ -0,0 +1,133 @@ +/* + * 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 + * . + * + */ + +#include + +#include "SettingControl.h" +#include "utils/log.h" +#include "utils/StringUtils.h" +#include "utils/XBMCTinyXML.h" + +bool CSettingControl::Deserialize(const TiXmlNode *node, bool update /* = false */) +{ + if (node == NULL) + return false; + + const TiXmlElement *elem = node->ToElement(); + if (elem == NULL) + return false; + + const char *strTmp = elem->Attribute("type"); + if ((strTmp == NULL && !update && m_type == SettingControlTypeNone) || (strTmp != NULL && !setType(strTmp))) + { + CLog::Log(LOGERROR, "CSetting: error reading \"type\" attribute of "); + return false; + } + + strTmp = elem->Attribute("format"); + if ((strTmp == NULL && !update && m_format == SettingControlFormatNone) || (strTmp != NULL && !setFormat(strTmp))) + { + CLog::Log(LOGERROR, "CSetting: error reading \"format\" attribute of "); + return false; + } + + if ((strTmp = elem->Attribute("attributes")) != NULL && !setAttributes(strTmp)) + { + CLog::Log(LOGERROR, "CSetting: error reading \"attributes\" attribute of "); + return false; + } + + if ((strTmp = elem->Attribute("delayed")) != NULL) + { + if (!StringUtils::EqualsNoCase(strTmp, "false") && !StringUtils::EqualsNoCase(strTmp, "true")) + { + CLog::Log(LOGERROR, "CSetting: error reading \"delayed\" attribute of "); + return false; + } + else + m_delayed = StringUtils::EqualsNoCase(strTmp, "true"); + } + + return true; +} + +bool CSettingControl::setType(const std::string &strType) +{ + if (StringUtils::EqualsNoCase(strType, "toggle")) + m_type = SettingControlTypeCheckmark; + else if (StringUtils::EqualsNoCase(strType, "spinner")) + m_type = SettingControlTypeSpinner; + else if (StringUtils::EqualsNoCase(strType, "edit")) + { + m_type = SettingControlTypeEdit; + m_delayed = true; + } + else if (StringUtils::EqualsNoCase(strType, "button")) + m_type = SettingControlTypeButton; + else + return false; + + return true; +} + +bool CSettingControl::setFormat(const std::string &strFormat) +{ + if (StringUtils::EqualsNoCase(strFormat, "boolean")) + m_format = SettingControlFormatBoolean; + else if (StringUtils::EqualsNoCase(strFormat, "string")) + m_format = SettingControlFormatString; + else if (StringUtils::EqualsNoCase(strFormat, "integer")) + m_format = SettingControlFormatInteger; + else if (StringUtils::EqualsNoCase(strFormat, "number")) + m_format = SettingControlFormatNumber; + else if (StringUtils::EqualsNoCase(strFormat, "ip")) + m_format = SettingControlFormatIP; + else if (StringUtils::EqualsNoCase(strFormat, "md5")) + m_format = SettingControlFormatMD5; + else if (StringUtils::EqualsNoCase(strFormat, "path")) + m_format = SettingControlFormatPath; + else if (StringUtils::EqualsNoCase(strFormat, "addon")) + m_format = SettingControlFormatAddon; + else if (StringUtils::EqualsNoCase(strFormat, "action")) + m_format = SettingControlFormatAction; + else + return false; + + return true; +} + +bool CSettingControl::setAttributes(const std::string &strAttributes) +{ + std::vector attributeList = StringUtils::Split(strAttributes, ","); + + int controlAttributes = SettingControlAttributeNone; + for (std::vector::const_iterator attribute = attributeList.begin(); attribute != attributeList.end(); attribute++) + { + if (StringUtils::EqualsNoCase(*attribute, "hidden")) + controlAttributes |= (int)SettingControlAttributeHidden; + else if (StringUtils::EqualsNoCase(*attribute, "new")) + controlAttributes |= (int)SettingControlAttributeVerifyNew; + else + return false; + } + + m_attributes = (SettingControlAttribute)controlAttributes; + return true; +} \ No newline at end of file diff --git a/xbmc/settings/SettingControl.h b/xbmc/settings/SettingControl.h new file mode 100644 index 0000000000000..816108f223e81 --- /dev/null +++ b/xbmc/settings/SettingControl.h @@ -0,0 +1,84 @@ +#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 + * . + * + */ + +#include + +class TiXmlNode; + +typedef enum { + SettingControlTypeNone = 0, + SettingControlTypeCheckmark, + SettingControlTypeSpinner, + SettingControlTypeEdit, + SettingControlTypeButton +} SettingControlType; + +typedef enum { + SettingControlFormatNone = 0, + SettingControlFormatBoolean, + SettingControlFormatString, + SettingControlFormatInteger, + SettingControlFormatNumber, + SettingControlFormatIP, + SettingControlFormatMD5, + SettingControlFormatPath, + SettingControlFormatAddon, + SettingControlFormatAction +} SettingControlFormat; + +typedef enum { + SettingControlAttributeNone = 0x0, + SettingControlAttributeHidden = 0x1, + SettingControlAttributeVerifyNew = 0x2 +} SettingControlAttribute; + +class CSettingControl +{ +public: + CSettingControl(SettingControlType type = SettingControlTypeNone, + SettingControlFormat format = SettingControlFormatNone, + SettingControlAttribute attribute = SettingControlAttributeNone) + : m_type(type), m_format(format), m_attributes(attribute), + m_delayed(false) + { } + virtual ~CSettingControl() { } + + bool Deserialize(const TiXmlNode *node, bool update = false); + + SettingControlType GetType() const { return m_type; } + SettingControlFormat GetFormat() const { return m_format; } + SettingControlAttribute GetAttributes() const { return m_attributes; } + bool GetDelayed() const { return m_delayed; } + + void SetType(SettingControlType type) { m_type = type; } + void SetFormat(SettingControlFormat format) { m_format = format; } + void SetAttributes(SettingControlAttribute attributes) { m_attributes = attributes; } + +protected: + bool setType(const std::string &strType); + bool setFormat(const std::string &strFormat); + bool setAttributes(const std::string &strAttributes); + + SettingControlType m_type; + SettingControlFormat m_format; + SettingControlAttribute m_attributes; + bool m_delayed; +}; diff --git a/xbmc/settings/SettingDependency.cpp b/xbmc/settings/SettingDependency.cpp new file mode 100644 index 0000000000000..03772f9cb268a --- /dev/null +++ b/xbmc/settings/SettingDependency.cpp @@ -0,0 +1,252 @@ +/* + * 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 + * . + * + */ + +#include + +#include "SettingDependency.h" +#include "Setting.h" +#include "SettingsManager.h" +#include "utils/log.h" +#include "utils/StringUtils.h" +#include "utils/XBMCTinyXML.h" + +bool CSettingDependencyCondition::Deserialize(const TiXmlNode *node) +{ + if (!CSettingConditionItem::Deserialize(node)) + return false; + + const TiXmlElement *elem = node->ToElement(); + if (elem == NULL) + return false; + + m_target = SettingDependencyTargetSetting; + const char *strTarget = elem->Attribute("on"); + if (strTarget != NULL && !setTarget(strTarget)) + { + CLog::Log(LOGWARNING, "CSettingDependencyCondition: unknown target \"%s\"", strTarget); + return false; + } + + if (m_target != SettingDependencyTargetSetting && m_name.empty()) + { + CLog::Log(LOGWARNING, "CSettingDependencyCondition: missing name for dependency"); + return false; + } + + if (m_target == SettingDependencyTargetSetting) + { + if (m_setting.empty()) + { + CLog::Log(LOGWARNING, "CSettingDependencyCondition: missing setting for dependency"); + return false; + } + + m_name = m_setting; + } + + m_operator = SettingDependencyOperatorEquals; + const char *strOperator = elem->Attribute("operator"); + if (strOperator != NULL && !setOperator(strOperator)) + { + CLog::Log(LOGWARNING, "CSettingDependencyCondition: unknown operator \"%s\"", strOperator); + return false; + } + + return true; +} + +bool CSettingDependencyCondition::Check() const +{ + if (m_name.empty() || + m_target == SettingDependencyTargetNone || + m_operator == SettingDependencyOperatorNone || + m_settingsManager == NULL) + return false; + + bool result = false; + switch (m_target) + { + case SettingDependencyTargetSetting: + { + if (m_setting.empty()) + return false; + + const CSetting *setting = m_settingsManager->GetSetting(m_setting); + if (setting == NULL) + { + CLog::Log(LOGWARNING, "CSettingDependencyCondition: unable to check condition on unknown setting \"%s\"", m_setting.c_str()); + return false; + } + + if (m_operator == SettingDependencyOperatorEquals) + result = setting->Equals(m_value); + else if (m_operator == SettingDependencyOperatorContains) + result = (setting->ToString().find(m_value) != std::string::npos); + + break; + } + + case SettingDependencyTargetProperty: + { + result = m_settingsManager->GetConditions().Check(m_name, m_value, m_setting); + break; + } + + default: + return false; + } + + return result == !m_negated; +} + +bool CSettingDependencyCondition::setTarget(const std::string &target) +{ + if (StringUtils::EqualsNoCase(target, "setting")) + m_target = SettingDependencyTargetSetting; + else if (StringUtils::EqualsNoCase(target, "property")) + m_target = SettingDependencyTargetProperty; + else + return false; + + return true; +} + +bool CSettingDependencyCondition::setOperator(const std::string &op) +{ + size_t length = 0; + if (StringUtils::EndsWith(op, "is")) + { + m_operator = SettingDependencyOperatorEquals; + length = 2; + } + else if (StringUtils::EndsWith(op, "contains")) + { + m_operator = SettingDependencyOperatorContains; + length = 8; + } + + if (op.size() > length + 1) + return false; + if (op.size() == length + 1) + { + if (!StringUtils::StartsWith(op, "!")) + return false; + m_negated = true; + } + + return true; +} + +bool CSettingDependencyConditionCombination::Deserialize(const TiXmlNode *node) +{ + if (node == NULL) + return false; + + size_t numOperations = m_operations.size(); + size_t numValues = m_values.size(); + + if (!CSettingConditionCombination::Deserialize(node)) + return false; + + if (numOperations < m_operations.size()) + { + for (size_t i = numOperations; i < m_operations.size(); i++) + { + if (m_operations[i] == NULL) + continue; + + CSettingDependencyConditionCombination *combination = static_cast(m_operations[i].get()); + if (combination == NULL) + continue; + + const std::set& settings = combination->GetSettings(); + m_settings.insert(settings.begin(), settings.end()); + } + } + + if (numValues < m_values.size()) + { + for (size_t i = numValues; i < m_values.size(); i++) + { + if (m_values[i] == NULL) + continue; + + CSettingDependencyCondition *condition = static_cast(m_values[i].get()); + if (condition == NULL) + continue; + + std::string settingId = condition->GetSetting(); + if (!settingId.empty()) + m_settings.insert(settingId); + } + } + + return true; +} + +CSettingDependency::CSettingDependency(CSettingsManager *settingsManager /* = NULL */) + : CSettingCondition(settingsManager), + m_type(SettingDependencyTypeNone) +{ + m_operation = CBooleanLogicOperationPtr(new CSettingDependencyConditionCombination(m_settingsManager)); +} + +bool CSettingDependency::Deserialize(const TiXmlNode *node) +{ + if (node == NULL) + return false; + + const TiXmlElement *elem = node->ToElement(); + if (elem == NULL) + return false; + + const char *strType = elem->Attribute("type"); + if (strType == NULL || strlen(strType) <= 0 || !setType(strType)) + { + CLog::Log(LOGWARNING, "CSettingDependency: missing or unknown dependency type definition"); + return false; + } + + return CSettingCondition::Deserialize(node); +} + +std::set CSettingDependency::GetSettings() const +{ + if (m_operation == NULL) + return std::set(); + + CSettingDependencyConditionCombination *combination = static_cast(m_operation.get()); + if (combination == NULL) + return std::set(); + + return combination->GetSettings(); +} + +bool CSettingDependency::setType(const std::string &type) +{ + if (StringUtils::EqualsNoCase(type, "enable")) + m_type = SettingDependencyTypeEnable; + else if (StringUtils::EqualsNoCase(type, "update")) + m_type = SettingDependencyTypeUpdate; + else + return false; + + return true; +} diff --git a/xbmc/settings/SettingDependency.h b/xbmc/settings/SettingDependency.h new file mode 100644 index 0000000000000..fb2e0964a1d51 --- /dev/null +++ b/xbmc/settings/SettingDependency.h @@ -0,0 +1,109 @@ +#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 + * . + * + */ + +#include +#include +#include + +#include "SettingConditions.h" +#include "utils/BooleanLogic.h" + +typedef enum { + SettingDependencyTypeNone = 0, + SettingDependencyTypeEnable, + SettingDependencyTypeUpdate +} SettingDependencyType; + +typedef enum { + SettingDependencyOperatorNone = 0, + SettingDependencyOperatorEquals, + SettingDependencyOperatorContains +} SettingDependencyOperator; + +typedef enum { + SettingDependencyTargetNone = 0, + SettingDependencyTargetSetting, + SettingDependencyTargetProperty +} SettingDependencyTarget; + +class CSettingDependencyCondition : public CSettingConditionItem +{ +public: + CSettingDependencyCondition(CSettingsManager *settingsManager = NULL) + : CSettingConditionItem(settingsManager), + m_operator(SettingDependencyOperatorEquals) + { } + virtual ~CSettingDependencyCondition() { } + + virtual bool Deserialize(const TiXmlNode *node); + virtual bool Check() const; + + const std::string& GetName() const { return m_name; } + const std::string& GetSetting() const { return m_setting; } + const SettingDependencyTarget GetTarget() const { return m_target; } + const SettingDependencyOperator GetOperator() const { return m_operator; } + +private: + bool setTarget(const std::string &target); + bool setOperator(const std::string &op); + + SettingDependencyTarget m_target; + SettingDependencyOperator m_operator; +}; + +class CSettingDependencyConditionCombination : public CSettingConditionCombination +{ +public: + CSettingDependencyConditionCombination(CSettingsManager *settingsManager = NULL) + : CSettingConditionCombination(settingsManager) + { } + virtual ~CSettingDependencyConditionCombination() { } + + virtual bool Deserialize(const TiXmlNode *node); + + const std::set& GetSettings() const { return m_settings; } + +private: + virtual CBooleanLogicOperation* newOperation() { return new CSettingDependencyConditionCombination(m_settingsManager); } + virtual CBooleanLogicValue* newValue() { return new CSettingDependencyCondition(m_settingsManager); } + + std::set m_settings; +}; + +class CSettingDependency : public CSettingCondition +{ +public: + CSettingDependency(CSettingsManager *settingsManager = NULL); + virtual ~CSettingDependency() { } + + virtual bool Deserialize(const TiXmlNode *node); + + SettingDependencyType GetType() const { return m_type; } + std::set GetSettings() const; + +private: + bool setType(const std::string &type); + + SettingDependencyType m_type; +}; + +typedef std::list SettingDependencies; +typedef std::map SettingDependencyMap; diff --git a/xbmc/settings/SettingPath.cpp b/xbmc/settings/SettingPath.cpp new file mode 100644 index 0000000000000..26b331a6543f9 --- /dev/null +++ b/xbmc/settings/SettingPath.cpp @@ -0,0 +1,115 @@ +/* + * 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 + * . + * + */ + +#include "SettingPath.h" +#include "settings/SettingsManager.h" +#include "threads/SingleLock.h" +#include "utils/log.h" +#include "utils/StringUtils.h" +#include "utils/XBMCTinyXML.h" +#include "utils/XMLUtils.h" + +#define XML_ELM_DEFAULT "default" +#define XML_ELM_CONSTRAINTS "constraints" + +CSettingPath::CSettingPath(const std::string &id, CSettingsManager *settingsManager /* = NULL */) + : CSettingString(id, settingsManager), + m_writable(true) +{ + m_control.SetType(SettingControlTypeButton); + m_control.SetFormat(SettingControlFormatPath); + m_control.SetAttributes(SettingControlAttributeNone); +} + +CSettingPath::CSettingPath(const std::string &id, const CSettingPath &setting) + : CSettingString(id, setting) +{ + copy(setting); +} + +bool CSettingPath::Deserialize(const TiXmlNode *node, bool update /* = false */) +{ + CSingleLock lock(m_critical); + + if (!CSettingString::Deserialize(node, update)) + return false; + + if (m_control.GetType() != SettingControlTypeButton || + m_control.GetFormat() != SettingControlFormatPath || + m_control.GetAttributes() != SettingControlAttributeNone) + { + CLog::Log(LOGERROR, "CSettingPath: invalid of \"%s\"", m_id.c_str()); + return false; + } + + // get the default value by abusing the FromString + // implementation to parse the default value + CStdString value; + if (XMLUtils::GetString(node, XML_ELM_DEFAULT, value)) + m_value = m_default = value; + else if (!update && !m_allowEmpty) + { + CLog::Log(LOGERROR, "CSettingPath: error reading the default value of \"%s\"", m_id.c_str()); + return false; + } + + const TiXmlNode *constraints = node->FirstChild(XML_ELM_CONSTRAINTS); + if (constraints != NULL) + { + // get writable + XMLUtils::GetBoolean(constraints, "writable", m_writable); + + // get sources + const TiXmlNode *sources = constraints->FirstChild("sources"); + if (sources != NULL) + { + m_sources.clear(); + const TiXmlNode *source = sources->FirstChild("source"); + while (source != NULL) + { + std::string strSource = source->FirstChild()->ValueStr(); + if (!strSource.empty()) + m_sources.push_back(strSource); + + source = source->NextSibling("source"); + } + } + } + + return true; +} + +bool CSettingPath::SetValue(const std::string &value) +{ + // for backwards compatibility to Frodo + if (StringUtils::EqualsNoCase(value, "select folder") || + StringUtils::EqualsNoCase(value, "select writable folder")) + return CSettingString::SetValue(""); + + return CSettingString::SetValue(value); +} + +void CSettingPath::copy(const CSettingPath &setting) +{ + CSettingString::Copy(setting); + + m_writable = setting.m_writable; + m_sources = setting.m_sources; +} diff --git a/xbmc/settings/SettingPath.h b/xbmc/settings/SettingPath.h new file mode 100644 index 0000000000000..714913244ccb1 --- /dev/null +++ b/xbmc/settings/SettingPath.h @@ -0,0 +1,44 @@ +#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 + * . + * + */ + +#include + +#include "Setting.h" + +class CSettingPath : public CSettingString +{ +public: + CSettingPath(const std::string &id, CSettingsManager *settingsManager = NULL); + CSettingPath(const std::string &id, const CSettingPath &setting); + virtual ~CSettingPath() { } + + virtual bool Deserialize(const TiXmlNode *node, bool update = false); + virtual bool SetValue(const std::string &value); + + bool Writable() const { return m_writable; } + const std::vector& GetSources() const { return m_sources; } + +private: + void copy(const CSettingPath &setting); + + bool m_writable; + std::vector m_sources; +}; diff --git a/xbmc/settings/SettingSection.cpp b/xbmc/settings/SettingSection.cpp new file mode 100644 index 0000000000000..fa8ed07ad551b --- /dev/null +++ b/xbmc/settings/SettingSection.cpp @@ -0,0 +1,315 @@ +/* + * 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 + * . + * + */ + +#include "SettingSection.h" +#include "SettingsManager.h" +#include "utils/log.h" +#include "utils/StringUtils.h" +#include "utils/XBMCTinyXML.h" + +#define XML_CATEGORY "category" +#define XML_GROUP "group" + +template void addISetting(const TiXmlNode *node, const T &item, std::vector &items) +{ + if (node == NULL) + return; + + const TiXmlElement *element = node->ToElement(); + if (element == NULL) + return; + + // check if there is a "before" or "after" attribute to place the setting at a specific position + int position = -1; // -1 => end, 0 => before, 1 => after + const char *positionId = element->Attribute("before"); + if (positionId != NULL && strlen(positionId) > 0) + position = 0; + else if ((positionId = element->Attribute("after")) != NULL && strlen(positionId) > 0) + position = 1; + + if (positionId != NULL && strlen(positionId) > 0 && position >= 0) + { + for (typename std::vector::iterator it = items.begin(); it != items.end(); it++) + { + if (!StringUtils::EqualsNoCase((*it)->GetId(), positionId)) + continue; + + typename std::vector::iterator positionIt = it; + if (position == 1) + positionIt++; + + items.insert(positionIt, item); + return; + } + } + + items.push_back(item); +} + +CSettingGroup::CSettingGroup(const std::string &id, CSettingsManager *settingsManager /* = NULL */) + : ISetting(id, settingsManager) +{ } + +CSettingGroup::~CSettingGroup() +{ + for (SettingList::const_iterator setting = m_settings.begin(); setting != m_settings.end(); setting++) + delete *setting; + m_settings.clear(); +} + +bool CSettingGroup::Deserialize(const TiXmlNode *node, bool update /* = false */) +{ + // handle conditions + if (!ISetting::Deserialize(node, update)) + return false; + + const TiXmlElement *settingElement = node->FirstChildElement(XML_SETTING); + while (settingElement != NULL) + { + std::string settingId; + if (CSettingCategory::DeserializeIdentification(settingElement, settingId)) + { + CSetting *setting = NULL; + for (SettingList::iterator itSetting = m_settings.begin(); itSetting != m_settings.end(); itSetting++) + { + if ((*itSetting)->GetId() == settingId) + { + setting = *itSetting; + break; + } + } + + update = (setting != NULL); + if (!update) + { + const char* settingType = settingElement->Attribute(XML_ATTR_TYPE); + if (settingType == NULL || strlen(settingType) <= 0) + { + CLog::Log(LOGERROR, "CSettingGroup: unable to read setting type of \"%s\"", settingId.c_str()); + return false; + } + + setting = m_settingsManager->CreateSetting(settingType, settingId, m_settingsManager); + if (setting == NULL) + CLog::Log(LOGERROR, "CSettingGroup: unknown setting type \"%s\" of \"%s\"", settingType, settingId.c_str()); + } + + if (setting == NULL) + CLog::Log(LOGERROR, "CSettingGroup: unable to create new setting \"%s\"", settingId.c_str()); + else if (!setting->Deserialize(settingElement, update)) + { + CLog::Log(LOGWARNING, "CSettingGroup: unable to read setting \"%s\"", settingId.c_str()); + if (!update) + delete setting; + } + else if (!update) + addISetting(settingElement, setting, m_settings); + } + + settingElement = settingElement->NextSiblingElement(XML_SETTING); + } + + return true; +} + +SettingList CSettingGroup::GetSettings(SettingLevel level) const +{ + SettingList settings; + + for (SettingList::const_iterator it = m_settings.begin(); it != m_settings.end(); it++) + { + if ((*it)->GetLevel() <= level && (*it)->IsVisible()) + settings.push_back(*it); + } + + return settings; +} + +CSettingCategory::CSettingCategory(const std::string &id, CSettingsManager *settingsManager /* = NULL */) + : ISetting(id, settingsManager), + m_label(-1), m_help(-1), + m_accessCondition(settingsManager) +{ } + +CSettingCategory::~CSettingCategory() +{ + for (SettingGroupList::const_iterator it = m_groups.begin(); it != m_groups.end(); it++) + delete *it; + + m_groups.clear(); +} + +bool CSettingCategory::Deserialize(const TiXmlNode *node, bool update /* = false */) +{ + // handle conditions + if (!ISetting::Deserialize(node, update)) + return false; + + const TiXmlElement *element = node->ToElement(); + if (element == NULL) + return false; + + int tmp = -1; + if (element->QueryIntAttribute(XML_ATTR_LABEL, &tmp) == TIXML_SUCCESS && tmp > 0) + m_label = tmp; + if (element->QueryIntAttribute(XML_ATTR_HELP, &m_help) == TIXML_SUCCESS && m_help > 0) + m_help = tmp; + + const TiXmlNode *accessNode = node->FirstChild("access"); + if (accessNode != NULL && !m_accessCondition.Deserialize(accessNode)) + return false; + + const TiXmlNode *groupNode = node->FirstChildElement(XML_GROUP); + while (groupNode != NULL) + { + std::string groupId; + if (CSettingGroup::DeserializeIdentification(groupNode, groupId)) + { + CSettingGroup *group = NULL; + for (SettingGroupList::iterator itGroup = m_groups.begin(); itGroup != m_groups.end(); itGroup++) + { + if ((*itGroup)->GetId() == groupId) + { + group = *itGroup; + break; + } + } + + update = (group != NULL); + if (!update) + group = new CSettingGroup(groupId, m_settingsManager); + + if (group->Deserialize(groupNode, update)) + { + if (!update) + addISetting(groupNode, group, m_groups); + } + else + { + CLog::Log(LOGWARNING, "CSettingCategory: unable to read group \"%s\"", groupId.c_str()); + if (!update) + delete group; + } + } + + groupNode = groupNode->NextSibling(XML_GROUP); + } + + return true; +} + +SettingGroupList CSettingCategory::GetGroups(SettingLevel level) const +{ + SettingGroupList groups; + + for (SettingGroupList::const_iterator it = m_groups.begin(); it != m_groups.end(); it++) + { + if ((*it)->IsVisible() && (*it)->GetSettings(level).size() > 0) + groups.push_back(*it); + } + + return groups; +} + +bool CSettingCategory::CanAccess() const +{ + return m_accessCondition.Check(); +} + +CSettingSection::CSettingSection(const std::string &id, CSettingsManager *settingsManager /* = NULL */) + : ISetting(id, settingsManager), + m_label(-1), m_help(-1) +{ } + +CSettingSection::~CSettingSection() +{ + for (SettingCategoryList::const_iterator it = m_categories.begin(); it != m_categories.end(); it++) + delete *it; + + m_categories.clear(); +} + +bool CSettingSection::Deserialize(const TiXmlNode *node, bool update /* = false */) +{ + // handle conditions + if (!ISetting::Deserialize(node, update)) + return false; + + const TiXmlElement *element = node->ToElement(); + if (element == NULL) + return false; + + int tmp = -1; + if (element->QueryIntAttribute(XML_ATTR_LABEL, &tmp) == TIXML_SUCCESS && tmp > 0) + m_label = tmp; + if (element->QueryIntAttribute(XML_ATTR_HELP, &tmp) == TIXML_SUCCESS && tmp > 0) + m_help = tmp; + + const TiXmlNode *categoryNode = node->FirstChild(XML_CATEGORY); + while (categoryNode != NULL) + { + std::string categoryId; + if (CSettingCategory::DeserializeIdentification(categoryNode, categoryId)) + { + CSettingCategory *category = NULL; + for (SettingCategoryList::iterator itCategory = m_categories.begin(); itCategory != m_categories.end(); itCategory++) + { + if ((*itCategory)->GetId() == categoryId) + { + category = *itCategory; + break; + } + } + + update = (category != NULL); + if (!update) + category = new CSettingCategory(categoryId, m_settingsManager); + + if (category->Deserialize(categoryNode, update)) + { + if (!update) + addISetting(categoryNode, category, m_categories); + } + else + { + CLog::Log(LOGWARNING, "CSettingSection: unable to read category \"%s\"", categoryId.c_str()); + if (!update) + delete category; + } + } + + categoryNode = categoryNode->NextSibling(XML_CATEGORY); + } + + return true; +} + +SettingCategoryList CSettingSection::GetCategories(SettingLevel level) const +{ + SettingCategoryList categories; + + for (SettingCategoryList::const_iterator it = m_categories.begin(); it != m_categories.end(); it++) + { + if ((*it)->IsVisible() && (*it)->GetGroups(level).size() > 0) + categories.push_back(*it); + } + + return categories; +} diff --git a/xbmc/settings/SettingSection.h b/xbmc/settings/SettingSection.h new file mode 100644 index 0000000000000..5ad2c2dd3f20f --- /dev/null +++ b/xbmc/settings/SettingSection.h @@ -0,0 +1,107 @@ +#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 + * . + * + */ + +#include +#include + +#include "ISetting.h" +#include "Setting.h" +#include "SettingCategoryAccess.h" + +class CSettingsManager; + +/*! + \ingroup settings + \brief Group of settings being part of a category + \sa CSettingCategory + \sa CSetting + */ +class CSettingGroup : public ISetting +{ +public: + CSettingGroup(const std::string &id, CSettingsManager *settingsManager = NULL); + ~CSettingGroup(); + + virtual bool Deserialize(const TiXmlNode *node, bool update = false); + + const SettingList& GetSettings() const { return m_settings; } + SettingList GetSettings(SettingLevel level) const; + +private: + SettingList m_settings; +}; + +typedef std::vector SettingGroupList; + +/*! + \ingroup settings + \brief Category of groups of settings being part of a section + \sa CSettingSection + \sa CSettingGroup + */ +class CSettingCategory : public ISetting +{ +public: + CSettingCategory(const std::string &id, CSettingsManager *settingsManager = NULL); + ~CSettingCategory(); + + virtual bool Deserialize(const TiXmlNode *node, bool update = false); + + const int GetLabel() const { return m_label; } + const int GetHelp() const { return m_help; } + const SettingGroupList& GetGroups() const { return m_groups; } + SettingGroupList GetGroups(SettingLevel level) const; + + bool CanAccess() const; + +private: + int m_label; + int m_help; + SettingGroupList m_groups; + CSettingCategoryAccess m_accessCondition; +}; + +typedef std::vector SettingCategoryList; + +/*! + \ingroup settings + \brief Section of setting categories + \sa CSettings + \sa CSettingCategory + */ +class CSettingSection : public ISetting +{ +public: + CSettingSection(const std::string &id, CSettingsManager *settingsManager = NULL); + ~CSettingSection(); + + virtual bool Deserialize(const TiXmlNode *node, bool update = false); + + const int GetLabel() const { return m_label; } + const int GetHelp() const { return m_help; } + const SettingCategoryList& GetCategories() const { return m_categories; } + SettingCategoryList GetCategories(SettingLevel level) const; + +private: + int m_label; + int m_help; + SettingCategoryList m_categories; +}; diff --git a/xbmc/settings/SettingUpdate.cpp b/xbmc/settings/SettingUpdate.cpp new file mode 100644 index 0000000000000..43ce87e9d8324 --- /dev/null +++ b/xbmc/settings/SettingUpdate.cpp @@ -0,0 +1,75 @@ +/* + * 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 + * . + * + */ + +#include "SettingUpdate.h" +#include "utils/log.h" +#include "utils/StringUtils.h" +#include "utils/XBMCTinyXML.h" + +CSettingUpdate::CSettingUpdate() + : m_type(SettingUpdateTypeNone) +{ } + +bool CSettingUpdate::operator<(const CSettingUpdate& rhs) const +{ + return m_type < rhs.m_type && m_value < rhs.m_value; +} + +bool CSettingUpdate::Deserialize(const TiXmlNode *node) +{ + if (node == NULL) + return false; + + const TiXmlElement *elem = node->ToElement(); + if (elem == NULL) + return false; + + const char *strType = elem->Attribute("type"); + if (strType == NULL || strlen(strType) <= 0 || !setType(strType)) + { + CLog::Log(LOGWARNING, "CSettingUpdate: missing or unknown update type definition"); + return false; + } + + if (m_type == SettingUpdateTypeRename) + { + if (node->FirstChild() == NULL || node->FirstChild()->Type() != TiXmlNode::TINYXML_TEXT) + { + CLog::Log(LOGWARNING, "CSettingUpdate: missing or invalid setting id for rename update definition"); + return false; + } + + m_value = node->FirstChild()->ValueStr(); + } + + return true; +} + +bool CSettingUpdate::setType(const std::string &type) +{ + if (StringUtils::EqualsNoCase(type, "change")) + m_type = SettingUpdateTypeChange; + else if (StringUtils::EqualsNoCase(type, "rename")) + m_type = SettingUpdateTypeRename; + else + return false; + + return true; +} diff --git a/xbmc/settings/SettingUpdate.h b/xbmc/settings/SettingUpdate.h new file mode 100644 index 0000000000000..e8ad966b58840 --- /dev/null +++ b/xbmc/settings/SettingUpdate.h @@ -0,0 +1,50 @@ +#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 + * . + * + */ + +#include + +class TiXmlNode; + +typedef enum { + SettingUpdateTypeNone = 0, + SettingUpdateTypeRename, + SettingUpdateTypeChange +} SettingUpdateType; + +class CSettingUpdate +{ +public: + CSettingUpdate(); + virtual ~CSettingUpdate() { } + + bool operator<(const CSettingUpdate& rhs) const; + + virtual bool Deserialize(const TiXmlNode *node); + + SettingUpdateType GetType() const { return m_type; } + const std::string& GetValue() const { return m_value; } + +private: + bool setType(const std::string &type); + + SettingUpdateType m_type; + std::string m_value; +}; diff --git a/xbmc/settings/SettingVisibility.cpp b/xbmc/settings/SettingVisibility.cpp new file mode 100644 index 0000000000000..a702a6d14fa1c --- /dev/null +++ b/xbmc/settings/SettingVisibility.cpp @@ -0,0 +1,48 @@ +/* + * 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 + * . + * + */ + +#include "SettingVisibility.h" +#include "SettingsManager.h" + +bool CSettingVisibilityCondition::Check() const +{ + if (m_settingsManager == NULL) + return false; + + bool found = m_settingsManager->GetConditions().Check("IsDefined", m_value); + if (m_negated) + return !found; + + return found; +} + +bool CSettingVisibilityConditionCombination::Check() const +{ + if (m_operations.empty() && m_values.empty()) + return true; + + return CSettingConditionCombination::Check(); +} + +CSettingVisibility::CSettingVisibility(CSettingsManager *settingsManager /* = NULL */) + : CSettingCondition(settingsManager) +{ + m_operation = CBooleanLogicOperationPtr(new CSettingVisibilityConditionCombination(m_settingsManager)); +} diff --git a/xbmc/settings/SettingVisibility.h b/xbmc/settings/SettingVisibility.h new file mode 100644 index 0000000000000..6f48e9998b01c --- /dev/null +++ b/xbmc/settings/SettingVisibility.h @@ -0,0 +1,58 @@ +#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 + * . + * + */ + +#include +#include + +#include "SettingConditions.h" + +class CSettingVisibilityCondition : public CSettingConditionItem +{ +public: + CSettingVisibilityCondition(CSettingsManager *settingsManager = NULL) + : CSettingConditionItem(settingsManager) + { } + virtual ~CSettingVisibilityCondition() { } + + virtual bool Check() const; +}; + +class CSettingVisibilityConditionCombination : public CSettingConditionCombination +{ +public: + CSettingVisibilityConditionCombination(CSettingsManager *settingsManager = NULL) + : CSettingConditionCombination(settingsManager) + { } + virtual ~CSettingVisibilityConditionCombination() { } + + virtual bool Check() const; + +private: + virtual CBooleanLogicOperation* newOperation() { return new CSettingVisibilityConditionCombination(m_settingsManager); } + virtual CBooleanLogicValue* newValue() { return new CSettingVisibilityCondition(m_settingsManager); } +}; + +class CSettingVisibility : public CSettingCondition +{ +public: + CSettingVisibility(CSettingsManager *settingsManager = NULL); + virtual ~CSettingVisibility() { } +}; diff --git a/xbmc/settings/Settings.cpp b/xbmc/settings/Settings.cpp index 1083e236a5272..64b7bd574fac1 100644 --- a/xbmc/settings/Settings.cpp +++ b/xbmc/settings/Settings.cpp @@ -18,216 +18,959 @@ * */ +#include "system.h" + #include "Settings.h" +#include "Application.h" +#include "Autorun.h" +#include "GUIPassword.h" +#include "LangInfo.h" +#include "Util.h" +#include "addons/AddonManager.h" +#include "addons/Skin.h" +#include "cores/AudioEngine/AEFactory.h" +#if defined(HAVE_LIBCRYSTALHD) +#include "cores/dvdplayer/DVDCodecs/Video/CrystalHD.h" +#endif // defined(HAVE_LIBCRYSTALHD) +#include "cores/playercorefactory/PlayerCoreFactory.h" +#include "cores/VideoRenderers/BaseRenderer.h" #include "filesystem/File.h" +#include "guilib/GraphicContext.h" +#include "guilib/GUIAudioManager.h" +#include "guilib/GUIFontManager.h" +#include "guilib/LocalizeStrings.h" +#include "input/MouseStat.h" +#if defined(TARGET_WINDOWS) +#include "input/windows/WINJoystick.h" +#elif defined(HAS_SDL_JOYSTICK) +#include "input/SDLJoystick.h" +#endif // defined(HAS_SDL_JOYSTICK) +#if defined(TARGET_LINUX) +#include "linux/LinuxTimezone.h" +#endif // defined(TARGET_LINUX) +#include "network/NetworkServices.h" +#include "network/upnp/UPnPSettings.h" +#if defined(TARGET_DARWIN_OSX) +#include "osx/XBMCHelper.h" +#include "cores/AudioEngine/Engines/CoreAudio/CoreAudioHardware.h" +#endif // defined(TARGET_DARWIN_OSX) +#include "peripherals/Peripherals.h" +#include "powermanagement/PowerManager.h" #include "profiles/ProfilesManager.h" -#include "settings/GUISettings.h" +#include "pvr/PVRManager.h" +#include "pvr/windows/GUIWindowPVRGuide.h" +#include "settings/AdvancedSettings.h" +#include "settings/DisplaySettings.h" +#include "settings/MediaSettings.h" +#include "settings/MediaSourceSettings.h" +#include "settings/SettingAddon.h" +#include "settings/SettingsManager.h" +#include "settings/SettingPath.h" +#include "settings/SkinSettings.h" #include "threads/SingleLock.h" +#include "utils/CharsetConverter.h" #include "utils/log.h" +#include "utils/RssManager.h" +#include "utils/StringUtils.h" +#include "utils/SystemInfo.h" +#include "utils/Weather.h" #include "utils/XBMCTinyXML.h" +#include "view/ViewStateSettings.h" +#include "windowing/WindowingFactory.h" + +#define SETTINGS_XML_FOLDER "special://xbmc/system/settings/" +#define SETTINGS_XML_ROOT "settings" -using namespace std; using namespace XFILE; -CSettings::CSettings(void) +bool AddonHasSettings(const std::string &condition, const std::string &value, const std::string &settingId) { + if (settingId.empty()) + return false; + + CSettingAddon *setting = (CSettingAddon*)CSettings::Get().GetSetting(settingId); + if (setting == NULL) + return false; + + ADDON::AddonPtr addon; + if (!ADDON::CAddonMgr::Get().GetAddon(setting->GetValue(), addon, setting->GetAddonType()) || addon == NULL) + return false; + + return addon->HasSettings(); } -void CSettings::RegisterSettingsHandler(ISettingsHandler *settingsHandler) +bool CheckMasterLock(const std::string &condition, const std::string &value, const std::string &settingId) { - if (settingsHandler == NULL) - return; + return g_passwordManager.IsMasterLockUnlocked(StringUtils::EqualsNoCase(value, "true")); +} - CSingleLock lock(m_critical); - m_settingsHandlers.insert(settingsHandler); +bool CheckPVRParentalPin(const std::string &condition, const std::string &value, const std::string &settingId) +{ + return PVR::g_PVRManager.CheckParentalPIN(g_localizeStrings.Get(19262).c_str()); } -void CSettings::UnregisterSettingsHandler(ISettingsHandler *settingsHandler) +bool HasPeripherals(const std::string &condition, const std::string &value, const std::string &settingId) { - if (settingsHandler == NULL) - return; + return PERIPHERALS::g_peripherals.GetNumberOfPeripherals() > 0; +} - CSingleLock lock(m_critical); - m_settingsHandlers.erase(settingsHandler); +bool IsFullscreen(const std::string &condition, const std::string &value, const std::string &settingId) +{ + return g_Windowing.IsFullScreen(); } -void CSettings::RegisterSubSettings(ISubSettings *subSettings) +bool IsMasterUser(const std::string &condition, const std::string &value, const std::string &settingId) { - if (subSettings == NULL) - return; + return g_passwordManager.bMasterUser; +} - CSingleLock lock(m_critical); - m_subSettings.insert(subSettings); +bool IsUsingTTFSubtitles(const std::string &condition, const std::string &value, const std::string &settingId) +{ + return CUtil::IsUsingTTFSubtitles(); } -void CSettings::UnregisterSubSettings(ISubSettings *subSettings) +bool ProfileCanWriteDatabase(const std::string &condition, const std::string &value, const std::string &settingId) { - if (subSettings == NULL) - return; + return CProfilesManager::Get().GetCurrentProfile().canWriteDatabases(); +} - CSingleLock lock(m_critical); - m_subSettings.erase(subSettings); +bool ProfileCanWriteSources(const std::string &condition, const std::string &value, const std::string &settingId) +{ + return CProfilesManager::Get().GetCurrentProfile().canWriteSources(); } -CSettings::~CSettings(void) +bool ProfileHasAddons(const std::string &condition, const std::string &value, const std::string &settingId) { - // 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(); + return CProfilesManager::Get().GetCurrentProfile().hasAddons(); +} - Clear(); +bool ProfileHasDatabase(const std::string &condition, const std::string &value, const std::string &settingId) +{ + return CProfilesManager::Get().GetCurrentProfile().hasDatabases(); } -void CSettings::Save() const +bool ProfileHasSources(const std::string &condition, const std::string &value, const std::string &settingId) { - if (!SaveSettings(CProfilesManager::Get().GetSettingsFile())) - CLog::Log(LOGERROR, "Unable to save settings to %s", CProfilesManager::Get().GetSettingsFile().c_str()); + return CProfilesManager::Get().GetCurrentProfile().hasSources(); } -bool CSettings::Reset() +bool ProfileHasAddonManagerLocked(const std::string &condition, const std::string &value, const std::string &settingId) { - CLog::Log(LOGINFO, "Resetting settings"); - CFile::Delete(CProfilesManager::Get().GetSettingsFile()); - Save(); - return LoadSettings(CProfilesManager::Get().GetSettingsFile()); + return CProfilesManager::Get().GetCurrentProfile().addonmanagerLocked(); } -bool CSettings::Load() +bool ProfileHasFilesLocked(const std::string &condition, const std::string &value, const std::string &settingId) +{ + return CProfilesManager::Get().GetCurrentProfile().filesLocked(); +} + +bool ProfileHasMusicLocked(const std::string &condition, const std::string &value, const std::string &settingId) +{ + return CProfilesManager::Get().GetCurrentProfile().musicLocked(); +} + +bool ProfileHasPicturesLocked(const std::string &condition, const std::string &value, const std::string &settingId) +{ + return CProfilesManager::Get().GetCurrentProfile().picturesLocked(); +} + +bool ProfileHasProgramsLocked(const std::string &condition, const std::string &value, const std::string &settingId) { - if (!OnSettingsLoading()) + return CProfilesManager::Get().GetCurrentProfile().programsLocked(); +} + +bool ProfileHasSettingsLocked(const std::string &condition, const std::string &value, const std::string &settingId) +{ + return CProfilesManager::Get().GetCurrentProfile().settingsLocked(); +} + +bool ProfileHasVideosLocked(const std::string &condition, const std::string &value, const std::string &settingId) +{ + return CProfilesManager::Get().GetCurrentProfile().videoLocked(); +} + +bool ProfileLockMode(const std::string &condition, const std::string &value, const std::string &settingId) +{ + char *tmp = NULL; + LockType lock = (LockType)strtol(value.c_str(), &tmp, 0); + if (tmp != NULL && *tmp != '\0') return false; - CLog::Log(LOGNOTICE, "loading %s", CProfilesManager::Get().GetSettingsFile().c_str()); - if (!LoadSettings(CProfilesManager::Get().GetSettingsFile())) - { - CLog::Log(LOGERROR, "Unable to load %s, creating new %s with default values", CProfilesManager::Get().GetSettingsFile().c_str(), CProfilesManager::Get().GetSettingsFile().c_str()); - if (!Reset()) - return false; - } + return CProfilesManager::Get().GetCurrentProfile().getLockMode() == lock; +} + +CSettings::CSettings() + : m_initialized(false) +{ + m_settingsManager = new CSettingsManager(); +} + +CSettings::~CSettings() +{ + Uninitialize(); + + delete m_settingsManager; +} + +CSettings& CSettings::Get() +{ + static CSettings sSettings; + return sSettings; +} + +CSetting* CSettings::CreateSetting(const std::string &settingType, const std::string &settingId, CSettingsManager *settingsManager /* = NULL */) const +{ + if (StringUtils::EqualsNoCase(settingType, "addon")) + return new CSettingAddon(settingId, settingsManager); + else if (StringUtils::EqualsNoCase(settingType, "path")) + return new CSettingPath(settingId, settingsManager); + + return NULL; +} + +bool CSettings::Initialize() +{ + CSingleLock lock(m_critical); + if (m_initialized) + return false; + + // register custom setting types + InitializeSettingTypes(); + + // option fillers and conditions need to be + // initialized before the setting definitions + InitializeOptionFillers(); + InitializeConditions(); + + // load the settings definitions + if (!InitializeDefinitions()) + return false; - OnSettingsLoaded(); + InitializeVisibility(); + InitializeDefaults(); + m_settingsManager->SetInitialized(); + + InitializeISettingsHandlers(); + InitializeISubSettings(); + InitializeISettingCallbacks(); + + m_initialized = true; return true; } -bool CSettings::LoadSettings(const CStdString& strSettingsFile) +bool CSettings::Load() +{ + return Load(CProfilesManager::Get().GetSettingsFile()); +} + +bool CSettings::Load(const std::string &file) { - // load the xml file CXBMCTinyXML xmlDoc; - if (!xmlDoc.LoadFile(strSettingsFile)) + if (!xmlDoc.LoadFile(file)) { - CLog::Log(LOGERROR, "%s, Line %d\n%s", strSettingsFile.c_str(), xmlDoc.ErrorRow(), xmlDoc.ErrorDesc()); + CLog::Log(LOGERROR, "CSettings: error loading settings from %s, Line %d\n%s", file.c_str(), xmlDoc.ErrorRow(), xmlDoc.ErrorDesc()); return false; } - TiXmlElement *pRootElement = xmlDoc.RootElement(); - if (strcmpi(pRootElement->Value(), "settings") != 0) + bool updated = false; + TiXmlElement *root = xmlDoc.RootElement(); + if (!m_settingsManager->Load(root, updated)) { - CLog::Log(LOGERROR, "%s\nDoesn't contain ", strSettingsFile.c_str()); + CLog::Log(LOGERROR, "CSettingsManager: unable to load settings from %s, creating new default settings", file.c_str()); + if (!Reset()) + return false; + + if (!Load(file)) + return false; + } + // if the settings had to be updated, we need to save the changes + else if (updated) + return Save(file); + + return true; +} + +bool CSettings::Load(const TiXmlElement *root, bool hide /* = false */) +{ + if (root == NULL) return false; + + std::map *loadedSettings = NULL; + if (hide) + loadedSettings = new std::map(); + + bool updated; + // only trigger settings events if hiding is disabled + bool success = m_settingsManager->Load(root, updated, !hide, loadedSettings); + // if necessary hide all the loaded settings + if (success && hide && loadedSettings != NULL) + { + for(std::map::const_iterator setting = loadedSettings->begin(); setting != loadedSettings->end(); setting++) + setting->second->SetVisible(false); + + delete loadedSettings; } - g_guiSettings.LoadXML(pRootElement); - - // load any ISubSettings implementations - return Load(pRootElement); + return success; +} + +void CSettings::SetLoaded() +{ + m_settingsManager->SetLoaded(); } -bool CSettings::SaveSettings(const CStdString& strSettingsFile, CGUISettings *localSettings /* = NULL */) const +bool CSettings::Save() +{ + return Save(CProfilesManager::Get().GetSettingsFile()); +} + +bool CSettings::Save(const std::string &file) { CXBMCTinyXML xmlDoc; - TiXmlElement xmlRootElement("settings"); - TiXmlNode *pRoot = xmlDoc.InsertEndChild(xmlRootElement); - if (!pRoot) return false; - // write our tags one by one - just a big list for now (can be flashed up later) + TiXmlElement rootElement(SETTINGS_XML_ROOT); + TiXmlNode *root = xmlDoc.InsertEndChild(rootElement); + if (root == NULL) + return false; - if (!OnSettingsSaving()) + if (!m_settingsManager->Save(root)) return false; - if (localSettings) // local settings to save - localSettings->SaveXML(pRoot); - else // save the global settings - g_guiSettings.SaveXML(pRoot); + return xmlDoc.SaveFile(file); +} - OnSettingsSaved(); - - if (!Save(pRoot)) - return false; +void CSettings::Unload() +{ + CSingleLock lock(m_critical); + m_settingsManager->Unload(); +} + +void CSettings::Uninitialize() +{ + CSingleLock lock(m_critical); + if (!m_initialized) + return; + + // unregister setting option fillers + m_settingsManager->UnregisterSettingOptionsFiller("audiocdactions"); + m_settingsManager->UnregisterSettingOptionsFiller("audiocdencoders"); + m_settingsManager->UnregisterSettingOptionsFiller("audiodevices"); + m_settingsManager->UnregisterSettingOptionsFiller("audiodevicespassthrough"); + m_settingsManager->UnregisterSettingOptionsFiller("audiooutputmodes"); + m_settingsManager->UnregisterSettingOptionsFiller("charsets"); + m_settingsManager->UnregisterSettingOptionsFiller("epgguideviews"); + m_settingsManager->UnregisterSettingOptionsFiller("fontheights"); + m_settingsManager->UnregisterSettingOptionsFiller("fonts"); + m_settingsManager->UnregisterSettingOptionsFiller("languages"); + m_settingsManager->UnregisterSettingOptionsFiller("pvrstartlastchannel"); + m_settingsManager->UnregisterSettingOptionsFiller("refreshchangedelays"); + m_settingsManager->UnregisterSettingOptionsFiller("refreshrates"); + m_settingsManager->UnregisterSettingOptionsFiller("regions"); + m_settingsManager->UnregisterSettingOptionsFiller("rendermethods"); + m_settingsManager->UnregisterSettingOptionsFiller("resolutions"); + m_settingsManager->UnregisterSettingOptionsFiller("screens"); + m_settingsManager->UnregisterSettingOptionsFiller("shutdownstates"); + m_settingsManager->UnregisterSettingOptionsFiller("startupwindows"); + m_settingsManager->UnregisterSettingOptionsFiller("streamlanguages"); + m_settingsManager->UnregisterSettingOptionsFiller("skincolors"); + m_settingsManager->UnregisterSettingOptionsFiller("skinfonts"); + m_settingsManager->UnregisterSettingOptionsFiller("skinsounds"); + m_settingsManager->UnregisterSettingOptionsFiller("skinthemes"); +#if defined(TARGET_LINUX) + m_settingsManager->UnregisterSettingOptionsFiller("timezonecountries"); + m_settingsManager->UnregisterSettingOptionsFiller("timezones"); +#endif // defined(TARGET_LINUX) + m_settingsManager->UnregisterSettingOptionsFiller("verticalsyncs"); + + // unregister ISettingCallback implementations + m_settingsManager->UnregisterCallback(&g_advancedSettings); + m_settingsManager->UnregisterCallback(&CMediaSettings::Get()); + m_settingsManager->UnregisterCallback(&CDisplaySettings::Get()); + m_settingsManager->UnregisterCallback(&g_application); + m_settingsManager->UnregisterCallback(&g_audioManager); + m_settingsManager->UnregisterCallback(&g_charsetConverter); + m_settingsManager->UnregisterCallback(&g_graphicsContext); + m_settingsManager->UnregisterCallback(&g_langInfo); +#if defined(TARGET_WINDOWS) || defined(HAS_SDL_JOYSTICK) + m_settingsManager->UnregisterCallback(&g_Joystick); +#endif + m_settingsManager->UnregisterCallback(&g_Mouse); + m_settingsManager->UnregisterCallback(&CNetworkServices::Get()); + m_settingsManager->UnregisterCallback(&g_passwordManager); + m_settingsManager->UnregisterCallback(&PVR::g_PVRManager); + m_settingsManager->UnregisterCallback(&CRssManager::Get()); +#if defined(TARGET_LINUX) + m_settingsManager->UnregisterCallback(&g_timezone); +#endif // defined(TARGET_LINUX) + m_settingsManager->UnregisterCallback(&g_weatherManager); + m_settingsManager->UnregisterCallback(&PERIPHERALS::CPeripherals::Get()); + + // unregister ISubSettings implementations + m_settingsManager->UnregisterSubSettings(&g_application); + m_settingsManager->UnregisterSubSettings(&CDisplaySettings::Get()); + m_settingsManager->UnregisterSubSettings(&CMediaSettings::Get()); + m_settingsManager->UnregisterSubSettings(&CSkinSettings::Get()); + m_settingsManager->UnregisterSubSettings(&g_sysinfo); + m_settingsManager->UnregisterSubSettings(&CViewStateSettings::Get()); + + // unregister ISettingsHandler implementations + m_settingsManager->UnregisterSettingsHandler(&g_advancedSettings); + m_settingsManager->UnregisterSettingsHandler(&CMediaSourceSettings::Get()); + m_settingsManager->UnregisterSettingsHandler(&CPlayerCoreFactory::Get()); + m_settingsManager->UnregisterSettingsHandler(&CRssManager::Get()); +#ifdef HAS_UPNP + m_settingsManager->UnregisterSettingsHandler(&CUPnPSettings::Get()); +#endif + m_settingsManager->UnregisterSettingsHandler(&CProfilesManager::Get()); + m_settingsManager->UnregisterSettingsHandler(&g_application); + + // cleanup the settings manager + m_settingsManager->Clear(); + + m_initialized = false; +} + +void CSettings::RegisterCallback(ISettingCallback *callback, const std::set &settingList) +{ + m_settingsManager->RegisterCallback(callback, settingList); +} - // save the file - return xmlDoc.SaveFile(strSettingsFile); +void CSettings::UnregisterCallback(ISettingCallback *callback) +{ + m_settingsManager->UnregisterCallback(callback); } -void CSettings::Clear() +CSetting* CSettings::GetSetting(const std::string &id) const { - OnSettingsCleared(); + CSingleLock lock(m_critical); + if (id.empty()) + return NULL; - for (SubSettings::const_iterator it = m_subSettings.begin(); it != m_subSettings.end(); it++) - (*it)->Clear(); + return m_settingsManager->GetSetting(id); } -bool CSettings::OnSettingsLoading() +CSettingSection* CSettings::GetSection(const std::string §ion) const { CSingleLock lock(m_critical); - for (SettingsHandlers::const_iterator it = m_settingsHandlers.begin(); it != m_settingsHandlers.end(); it++) + if (section.empty()) + return NULL; + + return m_settingsManager->GetSection(section); +} + +SettingDependencyMap CSettings::GetDependencies(const std::string &id) const +{ + return m_settingsManager->GetDependencies(id); +} + +SettingDependencyMap CSettings::GetDependencies(const CSetting *setting) const +{ + return m_settingsManager->GetDependencies(setting); +} + +void* CSettings::GetSettingOptionsFiller(const CSetting *setting) +{ + return m_settingsManager->GetSettingOptionsFiller(setting); +} + +bool CSettings::GetBool(const std::string &id) const +{ + return m_settingsManager->GetBool(id); +} + +bool CSettings::SetBool(const std::string &id, bool value) +{ + return m_settingsManager->SetBool(id, value); +} + +bool CSettings::ToggleBool(const std::string &id) +{ + return m_settingsManager->ToggleBool(id); +} + +int CSettings::GetInt(const std::string &id) const +{ + return m_settingsManager->GetInt(id); +} + +bool CSettings::SetInt(const std::string &id, int value) +{ + return m_settingsManager->SetInt(id, value); +} + +double CSettings::GetNumber(const std::string &id) const +{ + return m_settingsManager->GetNumber(id); +} + +bool CSettings::SetNumber(const std::string &id, double value) +{ + return m_settingsManager->SetNumber(id, value); +} + +std::string CSettings::GetString(const std::string &id) const +{ + return m_settingsManager->GetString(id); +} + +bool CSettings::SetString(const std::string &id, const std::string &value) +{ + return m_settingsManager->SetString(id, value); +} + +bool CSettings::LoadSetting(const TiXmlNode *node, const std::string &settingId) +{ + return m_settingsManager->LoadSetting(node, settingId); +} + +bool CSettings::Initialize(const std::string &file) +{ + CXBMCTinyXML xmlDoc; + if (!xmlDoc.LoadFile(file.c_str())) { - if (!(*it)->OnSettingsLoading()) - return false; + CLog::Log(LOGERROR, "CSettings: error loading settings definition from %s, Line %d\n%s", file.c_str(), xmlDoc.ErrorRow(), xmlDoc.ErrorDesc()); + return false; + } + + TiXmlElement *root = xmlDoc.RootElement(); + if (root == NULL) + return false; + + return m_settingsManager->Initialize(root); +} + +bool CSettings::InitializeDefinitions() +{ + if (!Initialize(SETTINGS_XML_FOLDER "settings.xml")) + { + CLog::Log(LOGFATAL, "Unable to load settings definitions"); + return false; } +#if defined(TARGET_WINDOWS) + if (CFile::Exists(SETTINGS_XML_FOLDER "win32.xml") && !Initialize(SETTINGS_XML_FOLDER "win32.xml")) + CLog::Log(LOGFATAL, "Unable to load win32-specific settings definitions"); +#elif defined(TARGET_LINUX) + if (CFile::Exists(SETTINGS_XML_FOLDER "linux.xml") && !Initialize(SETTINGS_XML_FOLDER "linux.xml")) + CLog::Log(LOGFATAL, "Unable to load linux-specific settings definitions"); +#if defined(TARGET_DARWIN) + if (CFile::Exists(SETTINGS_XML_FOLDER "darwin.xml") && !Initialize(SETTINGS_XML_FOLDER "darwin.xml")) + CLog::Log(LOGFATAL, "Unable to load darwin-specific settings definitions"); +#if defined(TARGET_DARWIN_OSX) + if (CFile::Exists(SETTINGS_XML_FOLDER "darwin_osx.xml") && !Initialize(SETTINGS_XML_FOLDER "darwin_osx.xml")) + CLog::Log(LOGFATAL, "Unable to load osx-specific settings definitions"); +#elif defined(TARGET_DARWIN_IOS) + if (CFile::Exists(SETTINGS_XML_FOLDER "darwin_ios.xml") && !Initialize(SETTINGS_XML_FOLDER "darwin_ios.xml")) + CLog::Log(LOGFATAL, "Unable to load ios-specific settings definitions"); +#if defined(TARGET_DARWIN_IOS_ATV2) + if (CFile::Exists(SETTINGS_XML_FOLDER "darwin_ios_atv2.xml") && !Initialize(SETTINGS_XML_FOLDER "darwin_ios_atv2.xml")) + CLog::Log(LOGFATAL, "Unable to load atv2-specific settings definitions"); +#endif +#endif +#elif defined(TARGET_ANDROID) + if (CFile::Exists(SETTINGS_XML_FOLDER "android.xml") && !Initialize(SETTINGS_XML_FOLDER "android.xml")) + CLog::Log(LOGFATAL, "Unable to load android-specific settings definitions"); +#elif defined(TARGET_RASPBERRY_PI) + if (CFile::Exists(SETTINGS_XML_FOLDER "rbp.xml") && !Initialize(SETTINGS_XML_FOLDER "rbp.xml")) + CLog::Log(LOGFATAL, "Unable to load rbp-specific settings definitions"); +#elif defined(TARGET_FREEBSD) + if (CFile::Exists(SETTINGS_XML_FOLDER "freebsd.xml") && !Initialize(SETTINGS_XML_FOLDER "freebsd.xml")) + CLog::Log(LOGFATAL, "Unable to load freebsd-specific settings definitions"); +#endif +#endif + if (CFile::Exists(SETTINGS_XML_FOLDER "appliance.xml") && !Initialize(SETTINGS_XML_FOLDER "appliance.xml")) + CLog::Log(LOGFATAL, "Unable to load appliance-specific settings definitions"); return true; } -void CSettings::OnSettingsLoaded() +void CSettings::InitializeSettingTypes() { - CSingleLock lock(m_critical); - for (SettingsHandlers::const_iterator it = m_settingsHandlers.begin(); it != m_settingsHandlers.end(); it++) - (*it)->OnSettingsLoaded(); + // register "addon" and "path" setting types implemented by CSettingAddon + m_settingsManager->RegisterSettingType("addon", this); + m_settingsManager->RegisterSettingType("path", this); } -bool CSettings::OnSettingsSaving() const +void CSettings::InitializeVisibility() { - CSingleLock lock(m_critical); - for (SettingsHandlers::const_iterator it = m_settingsHandlers.begin(); it != m_settingsHandlers.end(); it++) + // hide some settings if necessary +#if defined(TARGET_LINUX) + CSettingString* timezonecountry = (CSettingString*)m_settingsManager->GetSetting("locale.timezonecountry"); + CSettingString* timezone = (CSettingString*)m_settingsManager->GetSetting("locale.timezone"); + #if defined(TARGET_DARWIN) + if (!g_sysinfo.IsAppleTV2() || GetIOSVersion() >= 4.3) { - if (!(*it)->OnSettingsSaving()) - return false; + timezonecountry->SetVisible(false); + timezone->SetVisible(false); } + #endif - return true; + if (timezonecountry->IsVisible()) + timezonecountry->SetDefault(g_timezone.GetCountryByTimezone(g_timezone.GetOSConfiguredTimezone())); + if (timezone->IsVisible()) + timezone->SetDefault(g_timezone.GetOSConfiguredTimezone()); +#endif } -void CSettings::OnSettingsSaved() const +void CSettings::InitializeDefaults() { - CSingleLock lock(m_critical); - for (SettingsHandlers::const_iterator it = m_settingsHandlers.begin(); it != m_settingsHandlers.end(); it++) - (*it)->OnSettingsSaved(); + // set some default values if necessary +#if defined(HAS_SKIN_TOUCHED) && defined(TARGET_DARWIN_IOS) && !defined(TARGET_DARWIN_IOS_ATV2) + ((CSettingAddon*)m_settingsManager->GetSetting("lookandfeel.skin"))->SetDefault("skin.touched"); +#endif + +#if defined(TARGET_WINDOWS) + #if defined(HAS_DX) + ((CSettingString*)m_settingsManager->GetSetting("musicplayer.visualisation"))->SetDefault("visualization.milkdrop"); + #endif + + #if !defined(HAS_GL) + // We prefer a fake fullscreen mode (window covering the screen rather than dedicated fullscreen) + // as it works nicer with switching to other applications. However on some systems vsync is broken + // when we do this (eg non-Aero on ATI in particular) and on others (AppleTV) we can't get XBMC to + // the front + if (g_sysinfo.IsAeroDisabled()) + ((CSettingBool*)m_settingsManager->GetSetting("videoscreen.fakefullscreen"))->SetDefault(false); + #endif +#endif + +#if defined(TARGET_DARWIN) + #if !defined(TARGET_DARWIN_IOS) + CStdString defaultAudioDeviceName; + CCoreAudioHardware::GetOutputDeviceName(defaultAudioDeviceName); + ((CSettingString*)m_settingsManager->GetSetting("audiooutput.audiodevice"))->SetDefault(defaultAudioDeviceName); + ((CSettingString*)m_settingsManager->GetSetting("audiooutput.passthroughdevice"))->SetDefault(defaultAudioDeviceName); + #endif +#else + ((CSettingString*)m_settingsManager->GetSetting("audiooutput.audiodevice"))->SetDefault(CAEFactory::GetDefaultDevice(false)); + ((CSettingString*)m_settingsManager->GetSetting("audiooutput.passthroughdevice"))->SetDefault(CAEFactory::GetDefaultDevice(true)); +#endif + + if (g_application.IsStandAlone()) + ((CSettingInt*)m_settingsManager->GetSetting("powermanagement.shutdownstate"))->SetDefault(POWERSTATE_SHUTDOWN); + +#if defined(HAS_WEB_SERVER) + if (CUtil::CanBindPrivileged()) + ((CSettingInt*)m_settingsManager->GetSetting("services.webserverport"))->SetDefault(80); +#endif } -void CSettings::OnSettingsCleared() +void CSettings::InitializeOptionFillers() { - CSingleLock lock(m_critical); - for (SettingsHandlers::const_iterator it = m_settingsHandlers.begin(); it != m_settingsHandlers.end(); it++) - (*it)->OnSettingsCleared(); + // register setting option fillers +#ifdef HAS_DVD_DRIVE + m_settingsManager->RegisterSettingOptionsFiller("audiocdactions", MEDIA_DETECT::CAutorun::SettingOptionAudioCdActionsFiller); + m_settingsManager->RegisterSettingOptionsFiller("audiocdencoders", MEDIA_DETECT::CAutorun::SettingOptionAudioCdEncodersFiller); +#endif + m_settingsManager->RegisterSettingOptionsFiller("audiodevices", CAEFactory::SettingOptionsAudioDevicesFiller); + m_settingsManager->RegisterSettingOptionsFiller("audiodevicespassthrough", CAEFactory::SettingOptionsAudioDevicesPassthroughFiller); + m_settingsManager->RegisterSettingOptionsFiller("audiooutputmodes", CAEFactory::SettingOptionsAudioOutputModesFiller); + m_settingsManager->RegisterSettingOptionsFiller("charsets", CCharsetConverter::SettingOptionsCharsetsFiller); + m_settingsManager->RegisterSettingOptionsFiller("epgguideviews", PVR::CGUIWindowPVRGuide::SettingOptionsEpgGuideViewFiller); + m_settingsManager->RegisterSettingOptionsFiller("fonts", GUIFontManager::SettingOptionsFontsFiller); + m_settingsManager->RegisterSettingOptionsFiller("languages", CLangInfo::SettingOptionsLanguagesFiller); + m_settingsManager->RegisterSettingOptionsFiller("pvrstartlastchannel", PVR::CPVRManager::SettingOptionsPvrStartLastChannelFiller); + m_settingsManager->RegisterSettingOptionsFiller("refreshchangedelays", CDisplaySettings::SettingOptionsRefreshChangeDelaysFiller); + m_settingsManager->RegisterSettingOptionsFiller("refreshrates", CDisplaySettings::SettingOptionsRefreshRatesFiller); + m_settingsManager->RegisterSettingOptionsFiller("regions", CLangInfo::SettingOptionsRegionsFiller); + m_settingsManager->RegisterSettingOptionsFiller("rendermethods", CBaseRenderer::SettingOptionsRenderMethodsFiller); + m_settingsManager->RegisterSettingOptionsFiller("resolutions", CDisplaySettings::SettingOptionsResolutionsFiller); + m_settingsManager->RegisterSettingOptionsFiller("screens", CDisplaySettings::SettingOptionsScreensFiller); + m_settingsManager->RegisterSettingOptionsFiller("shutdownstates", CPowerManager::SettingOptionsShutdownStatesFiller); + m_settingsManager->RegisterSettingOptionsFiller("startupwindows", ADDON::CSkinInfo::SettingOptionsStartupWindowsFiller); + m_settingsManager->RegisterSettingOptionsFiller("streamlanguages", CLangInfo::SettingOptionsStreamLanguagesFiller); + m_settingsManager->RegisterSettingOptionsFiller("skincolors", ADDON::CSkinInfo::SettingOptionsSkinColorsFiller); + m_settingsManager->RegisterSettingOptionsFiller("skinfonts", ADDON::CSkinInfo::SettingOptionsSkinFontsFiller); + m_settingsManager->RegisterSettingOptionsFiller("skinsounds", ADDON::CSkinInfo::SettingOptionsSkinSoundFiller); + m_settingsManager->RegisterSettingOptionsFiller("skinthemes", ADDON::CSkinInfo::SettingOptionsSkinThemesFiller); +#ifdef TARGET_LINUX + m_settingsManager->RegisterSettingOptionsFiller("timezonecountries", CLinuxTimezone::SettingOptionsTimezoneCountriesFiller); + m_settingsManager->RegisterSettingOptionsFiller("timezones", CLinuxTimezone::SettingOptionsTimezonesFiller); +#endif + m_settingsManager->RegisterSettingOptionsFiller("verticalsyncs", CDisplaySettings::SettingOptionsVerticalSyncsFiller); +} + +void CSettings::InitializeConditions() +{ + // add basic conditions + m_settingsManager->AddCondition("true"); +#ifdef HAS_AIRPLAY + m_settingsManager->AddCondition("has_airplay"); +#endif +#ifdef HAS_EVENT_SERVER + m_settingsManager->AddCondition("has_event_server"); +#endif +#ifdef HAS_GL + m_settingsManager->AddCondition("has_gl"); +#endif +#ifdef HAS_GLES + m_settingsManager->AddCondition("has_gles"); +#endif +#if HAS_GLES == 2 + m_settingsManager->AddCondition("has_glesv2"); +#endif +#ifdef HAS_KARAOKE + m_settingsManager->AddCondition("has_karaoke"); +#endif +#ifdef HAS_SDL_JOYSTICK + m_settingsManager->AddCondition("has_sdl_joystick"); +#endif +#ifdef HAS_SKIN_TOUCHED + m_settingsManager->AddCondition("has_skin_touched"); +#endif +#ifdef HAS_TIME_SERVER + m_settingsManager->AddCondition("has_time_server"); +#endif +#ifdef HAS_WEB_SERVER + m_settingsManager->AddCondition("has_web_server"); +#endif +#ifdef HAS_ZEROCONF + m_settingsManager->AddCondition("has_zeroconf"); +#endif +#ifdef HAVE_LIBCRYSTALHD + m_settingsManager->AddCondition("have_libcrystalhd"); + if (CCrystalHD::GetInstance()->DevicePresent()) + m_settingsManager->AddCondition("hascrystalhddevice"); +#endif +#ifdef HAVE_LIBOPENMAX + m_settingsManager->AddCondition("have_libopenmax"); +#endif +#ifdef HAVE_LIBVA + m_settingsManager->AddCondition("have_libva"); +#endif +#ifdef HAVE_LIBVDADECODER + m_settingsManager->AddCondition("have_libvdadecoder"); + if (g_sysinfo.HasVDADecoder()) + m_settingsManager->AddCondition("hasvdadecoder"); +#endif +#ifdef HAVE_LIBVDPAU + m_settingsManager->AddCondition("have_libvdpau"); +#endif +#ifdef HAVE_VIDEOTOOLBOXDECODER + m_settingsManager->AddCondition("have_videotoolboxdecoder"); + if (g_sysinfo.HasVideoToolBoxDecoder()) + m_settingsManager->AddCondition("hasvideotoolboxdecoder"); +#endif +#ifdef TARGET_DARWIN_IOS_ATV + if (g_sysinfo.IsAppleTV2()) + m_settingsManager->AddCondition("isappletv2"); +#endif +#if defined(TARGET_WINDOWS) && defined(HAS_DX) + m_settingsManager->AddCondition("has_dx"); + if (g_sysinfo.IsVistaOrHigher()) + m_settingsManager->AddCondition("hasdxva2"); +#endif + + if (g_application.IsStandAlone()) + m_settingsManager->AddCondition("isstandalone"); + + // add more complex conditions + m_settingsManager->AddCondition("addonhassettings", AddonHasSettings); + m_settingsManager->AddCondition("checkmasterlock", CheckMasterLock); + m_settingsManager->AddCondition("checkpvrparentalpin", CheckPVRParentalPin); + m_settingsManager->AddCondition("hasperipherals", HasPeripherals); + m_settingsManager->AddCondition("isfullscreen", IsFullscreen); + m_settingsManager->AddCondition("ismasteruser", IsMasterUser); + m_settingsManager->AddCondition("isusingttfsubtitles", IsUsingTTFSubtitles); + m_settingsManager->AddCondition("profilecanwritedatabase", ProfileCanWriteDatabase); + m_settingsManager->AddCondition("profilecanwritesources", ProfileCanWriteSources); + m_settingsManager->AddCondition("profilehasaddons", ProfileHasAddons); + m_settingsManager->AddCondition("profilehasdatabase", ProfileHasDatabase); + m_settingsManager->AddCondition("profilehassources", ProfileHasSources); + m_settingsManager->AddCondition("profilehasaddonmanagerlocked", ProfileHasAddonManagerLocked); + m_settingsManager->AddCondition("profilehasfileslocked", ProfileHasFilesLocked); + m_settingsManager->AddCondition("profilehasmusiclocked", ProfileHasMusicLocked); + m_settingsManager->AddCondition("profilehaspictureslocked", ProfileHasPicturesLocked); + m_settingsManager->AddCondition("profilehasprogramslocked", ProfileHasProgramsLocked); + m_settingsManager->AddCondition("profilehassettingslocked", ProfileHasSettingsLocked); + m_settingsManager->AddCondition("profilehasvideoslocked", ProfileHasVideosLocked); + m_settingsManager->AddCondition("profilelockmode", ProfileLockMode); } -bool CSettings::Load(const TiXmlNode *settings) +void CSettings::InitializeISettingsHandlers() { - bool ok = true; - for (SubSettings::const_iterator it = m_subSettings.begin(); it != m_subSettings.end(); it++) - ok &= (*it)->Load(settings); + // register ISettingsHandler implementations + m_settingsManager->RegisterSettingsHandler(&g_application); + m_settingsManager->RegisterSettingsHandler(&CProfilesManager::Get()); + m_settingsManager->RegisterSettingsHandler(&g_advancedSettings); + m_settingsManager->RegisterSettingsHandler(&CMediaSourceSettings::Get()); + m_settingsManager->RegisterSettingsHandler(&CPlayerCoreFactory::Get()); + m_settingsManager->RegisterSettingsHandler(&CRssManager::Get()); +#ifdef HAS_UPNP + m_settingsManager->RegisterSettingsHandler(&CUPnPSettings::Get()); +#endif +} - return ok; +void CSettings::InitializeISubSettings() +{ + // register ISubSettings implementations + m_settingsManager->RegisterSubSettings(&g_application); + m_settingsManager->RegisterSubSettings(&CDisplaySettings::Get()); + m_settingsManager->RegisterSubSettings(&CMediaSettings::Get()); + m_settingsManager->RegisterSubSettings(&CSkinSettings::Get()); + m_settingsManager->RegisterSubSettings(&g_sysinfo); + m_settingsManager->RegisterSubSettings(&CViewStateSettings::Get()); } -bool CSettings::Save(TiXmlNode *settings) const +void CSettings::InitializeISettingCallbacks() { - CSingleLock lock(m_critical); - for (SubSettings::const_iterator it = m_subSettings.begin(); it != m_subSettings.end(); it++) + // register any ISettingCallback implementations + std::set settingSet; + settingSet.insert("debug.showloginfo"); + m_settingsManager->RegisterCallback(&g_advancedSettings, settingSet); + + settingSet.clear(); + settingSet.insert("karaoke.export"); + settingSet.insert("karaoke.importcsv"); + settingSet.insert("musiclibrary.cleanup"); + settingSet.insert("musiclibrary.export"); + settingSet.insert("musiclibrary.import"); + settingSet.insert("musicfiles.trackformat"); + settingSet.insert("musicfiles.trackformatright"); + settingSet.insert("videolibrary.flattentvshows"); + settingSet.insert("videolibrary.removeduplicates"); + settingSet.insert("videolibrary.groupmoviesets"); + settingSet.insert("videolibrary.cleanup"); + settingSet.insert("videolibrary.import"); + settingSet.insert("videolibrary.export"); + m_settingsManager->RegisterCallback(&CMediaSettings::Get(), settingSet); + + settingSet.clear(); + settingSet.insert("videoscreen.screen"); + settingSet.insert("videoscreen.resolution"); + settingSet.insert("videoscreen.screenmode"); + m_settingsManager->RegisterCallback(&CDisplaySettings::Get(), settingSet); + + settingSet.clear(); + settingSet.insert("audiooutput.channels"); + settingSet.insert("audiooutput.guisoundmode"); + settingSet.insert("lookandfeel.skin"); + settingSet.insert("lookandfeel.skinsettings"); + settingSet.insert("lookandfeel.font"); + settingSet.insert("lookandfeel.skintheme"); + settingSet.insert("lookandfeel.skincolors"); + settingSet.insert("lookandfeel.skinzoom"); + settingSet.insert("musicplayer.replaygainpreamp"); + settingSet.insert("musicplayer.replaygainnogainpreamp"); + settingSet.insert("musicplayer.replaygaintype"); + settingSet.insert("musicplayer.replaygainavoidclipping"); + settingSet.insert("scrapers.musicvideosdefault"); + settingSet.insert("screensaver.mode"); + settingSet.insert("screensaver.preview"); + settingSet.insert("screensaver.settings"); + settingSet.insert("videoscreen.guicalibration"); + settingSet.insert("videoscreen.testpattern"); + m_settingsManager->RegisterCallback(&g_application, settingSet); + + settingSet.clear(); + settingSet.insert("lookandfeel.soundskin"); + m_settingsManager->RegisterCallback(&g_audioManager, settingSet); + + settingSet.clear(); + settingSet.insert("subtitles.charset"); + settingSet.insert("karaoke.charset"); + settingSet.insert("locale.charset"); + m_settingsManager->RegisterCallback(&g_charsetConverter, settingSet); + + settingSet.clear(); + settingSet.insert("videoscreen.fakefullscreen"); + m_settingsManager->RegisterCallback(&g_graphicsContext, settingSet); + + settingSet.clear(); + settingSet.insert("locale.audiolanguage"); + settingSet.insert("locale.subtitlelanguage"); + settingSet.insert("locale.language"); + settingSet.insert("locale.country"); + m_settingsManager->RegisterCallback(&g_langInfo, settingSet); + +#if defined(HAS_SDL_JOYSTICK) + settingSet.clear(); + settingSet.insert("input.enablejoystick"); + m_settingsManager->RegisterCallback(&g_Joystick, settingSet); +#endif + + settingSet.clear(); + settingSet.insert("input.enablemouse"); + m_settingsManager->RegisterCallback(&g_Mouse, settingSet); + + settingSet.clear(); + settingSet.insert("services.webserver"); + settingSet.insert("services.webserverport"); + settingSet.insert("services.webserverusername"); + settingSet.insert("services.webserverpassword"); + settingSet.insert("services.zeroconf"); + settingSet.insert("services.airplay"); + settingSet.insert("services.useairplaypassword"); + settingSet.insert("services.airplaypassword"); + settingSet.insert("services.upnpserver"); + settingSet.insert("services.upnprenderer"); + settingSet.insert("services.upnpcontroller"); + settingSet.insert("services.esenabled"); + settingSet.insert("services.esport"); + settingSet.insert("services.esallinterfaces"); + settingSet.insert("services.esinitialdelay"); + settingSet.insert("services.escontinuousdelay"); + settingSet.insert("smb.winsserver"); + settingSet.insert("smb.workgroup"); + m_settingsManager->RegisterCallback(&CNetworkServices::Get(), settingSet); + + settingSet.clear(); + settingSet.insert("masterlock.lockcode"); + m_settingsManager->RegisterCallback(&g_passwordManager, settingSet); + + settingSet.clear(); + settingSet.insert("pvrmanager.enabled"); + settingSet.insert("pvrmanager.channelmanager"); + settingSet.insert("pvrmanager.channelscan"); + settingSet.insert("pvrmanager.resetdb"); + settingSet.insert("pvrclient.menuhook"); + settingSet.insert("pvrmenu.searchicons"); + settingSet.insert("epg.resetepg"); + settingSet.insert("pvrparental.enabled"); + m_settingsManager->RegisterCallback(&PVR::g_PVRManager, settingSet); + + settingSet.clear(); + settingSet.insert("lookandfeel.rssedit"); + m_settingsManager->RegisterCallback(&CRssManager::Get(), settingSet); + +#if defined(TARGET_LINUX) + settingSet.clear(); + settingSet.insert("locale.timezone"); + settingSet.insert("locale.timezonecountry"); + m_settingsManager->RegisterCallback(&g_timezone, settingSet); +#endif + + settingSet.clear(); + settingSet.insert("weather.addon"); + settingSet.insert("weather.addonsettings"); + m_settingsManager->RegisterCallback(&g_weatherManager, settingSet); + + settingSet.clear(); + settingSet.insert("input.peripherals"); + settingSet.insert("locale.language"); + m_settingsManager->RegisterCallback(&PERIPHERALS::CPeripherals::Get(), settingSet); + +#if defined(TARGET_DARWIN_OSX) + settingSet.clear(); + settingSet.insert("input.appleremotemode"); + m_settingsManager->RegisterCallback(&XBMCHelper::GetInstance(), settingSet); +#endif +} + +bool CSettings::Reset() +{ + std::string settingsFile = CProfilesManager::Get().GetSettingsFile(); + // try to delete the settings file + if (XFILE::CFile::Exists(settingsFile, false) && !XFILE::CFile::Delete(settingsFile)) + CLog::Log(LOGWARNING, "Unable to delete old settings file at %s", settingsFile.c_str()); + + // unload any loaded settings + Unload(); + + // try to save the default settings + if (!Save()) { - if (!(*it)->Save(settings)) - return false; + CLog::Log(LOGWARNING, "Failed to save the default settings to %s", settingsFile.c_str()); + return false; } return true; diff --git a/xbmc/settings/Settings.h b/xbmc/settings/Settings.h index c525914f24533..7aa92bf58e936 100644 --- a/xbmc/settings/Settings.h +++ b/xbmc/settings/Settings.h @@ -20,56 +20,78 @@ */ #include +#include -#define PRE_SKIN_VERSION_9_10_COMPATIBILITY 1 -#define PRE_SKIN_VERSION_11_COMPATIBILITY 1 - -#include "settings/ISettingsHandler.h" -#include "settings/ISubSettings.h" +#include "settings/ISettingCallback.h" +#include "settings/ISettingCreator.h" +#include "settings/Setting.h" #include "threads/CriticalSection.h" -#include "utils/StdString.h" -class CGUISettings; +class CSettingSection; +class CSettingsManager; class TiXmlElement; class TiXmlNode; -class CSettings : private ISettingsHandler, ISubSettings +class CSettings : public ISettingCreator { public: - CSettings(void); - virtual ~CSettings(void); + CSettings(); + virtual ~CSettings(); + + static CSettings& Get(); - void RegisterSettingsHandler(ISettingsHandler *settingsHandler); - void UnregisterSettingsHandler(ISettingsHandler *settingsHandler); - void RegisterSubSettings(ISubSettings *subSettings); - void UnregisterSubSettings(ISubSettings *subSettings); + // implementation of ISettingCreator + virtual CSetting* CreateSetting(const std::string &settingType, const std::string &settingId, CSettingsManager *settingsManager = NULL) const; + bool Initialize(); bool Load(); - void Save() const; - bool SaveSettings(const CStdString& strSettingsFile, CGUISettings *localSettings = NULL) const; - bool Reset(); - void Clear(); + bool Load(const std::string &file); + bool Load(const TiXmlElement *root, bool hide = false); + void SetLoaded(); + bool Save(); + bool Save(const std::string &file); + void Unload(); + void Uninitialize(); -protected: - bool LoadSettings(const CStdString& strSettingsFile); + void RegisterCallback(ISettingCallback *callback, const std::set &settingList); + void UnregisterCallback(ISettingCallback *callback); -private: - // implementation of ISettingsHandler - virtual bool OnSettingsLoading(); - virtual void OnSettingsLoaded(); - virtual bool OnSettingsSaving() const; - virtual void OnSettingsSaved() const; - virtual void OnSettingsCleared(); + CSetting* GetSetting(const std::string &id) const; + CSettingSection* GetSection(const std::string §ion) const; + SettingDependencyMap GetDependencies(const std::string &id) const; + SettingDependencyMap GetDependencies(const CSetting *setting) const; + void* GetSettingOptionsFiller(const CSetting *setting); + + bool GetBool(const std::string &id) const; + int GetInt(const std::string &id) const; + double GetNumber(const std::string &id) const; + std::string GetString(const std::string &id) const; + + bool SetBool(const std::string &id, bool value); + bool ToggleBool(const std::string &id); + bool SetInt(const std::string &id, int value); + bool SetNumber(const std::string &id, double value); + bool SetString(const std::string &id, const std::string &value); - // implementation of ISubSettings - virtual bool Load(const TiXmlNode *settings); - virtual bool Save(TiXmlNode *settings) const; + bool LoadSetting(const TiXmlNode *node, const std::string &settingId); +private: + CSettings(const CSettings&); + CSettings const& operator=(CSettings const&); + + bool Initialize(const std::string &file); + bool InitializeDefinitions(); + void InitializeSettingTypes(); + void InitializeVisibility(); + void InitializeDefaults(); + void InitializeOptionFillers(); + void InitializeConditions(); + void InitializeISettingsHandlers(); + void InitializeISubSettings(); + void InitializeISettingCallbacks(); + bool Reset(); + + bool m_initialized; + CSettingsManager *m_settingsManager; CCriticalSection m_critical; - typedef std::set SettingsHandlers; - SettingsHandlers m_settingsHandlers; - typedef std::set SubSettings; - SubSettings m_subSettings; }; - -extern class CSettings g_settings; diff --git a/xbmc/settings/SettingsManager.cpp b/xbmc/settings/SettingsManager.cpp new file mode 100644 index 0000000000000..3bb1e399463be --- /dev/null +++ b/xbmc/settings/SettingsManager.cpp @@ -0,0 +1,882 @@ +/* + * 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 + * . + * + */ + +#include "SettingsManager.h" +#include "SettingSection.h" +#include "Setting.h" +#include "threads/SingleLock.h" +#include "utils/log.h" +#include "utils/StringUtils.h" +#include "utils/XBMCTinyXML.h" + +#define XML_ROOT "settings" +#define XML_SECTION "section" + + +CSettingsManager::CSettingsManager() + : m_initialized(false), m_loaded(false) +{ } + +CSettingsManager::~CSettingsManager() +{ + // 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(); + m_settingCreators.clear(); + + Clear(); +} + +bool CSettingsManager::Initialize(const TiXmlElement *root) +{ + CSingleLock lock(m_critical); + if (m_initialized || root == NULL) + return false; + + if (!StringUtils::EqualsNoCase(root->ValueStr(), XML_ROOT)) + { + CLog::Log(LOGERROR, "CSettingsManager: error reading settings definition: doesn't contain tag"); + return false; + } + + const TiXmlNode *sectionNode = root->FirstChild(XML_SECTION); + while (sectionNode != NULL) + { + std::string sectionId; + if (CSettingSection::DeserializeIdentification(sectionNode, sectionId)) + { + CSettingSection *section = NULL; + SettingSectionMap::iterator itSection = m_sections.find(sectionId); + bool update = (itSection != m_sections.end()); + if (!update) + section = new CSettingSection(sectionId, this); + else + section = itSection->second; + + if (section->Deserialize(sectionNode, update)) + { + section->CheckVisible(); + if (!update) + m_sections[section->GetId()] = section; + + // get all settings and add them to the settings map + for (SettingCategoryList::const_iterator categoryIt = section->GetCategories().begin(); categoryIt != section->GetCategories().end(); categoryIt++) + { + (*categoryIt)->CheckVisible(); + for (SettingGroupList::const_iterator groupIt = (*categoryIt)->GetGroups().begin(); groupIt != (*categoryIt)->GetGroups().end(); groupIt++) + { + (*groupIt)->CheckVisible(); + for (SettingList::const_iterator settingIt = (*groupIt)->GetSettings().begin(); settingIt != (*groupIt)->GetSettings().end(); settingIt++) + { + (*settingIt)->CheckVisible(); + + const std::string &settingId = (*settingIt)->GetId(); + SettingMap::iterator setting = m_settings.find(settingId); + if (setting == m_settings.end()) + { + Setting tmpSetting = { NULL }; + std::pair tmpIt = m_settings.insert(make_pair(settingId, tmpSetting)); + setting = tmpIt.first; + } + + if (setting->second.setting == NULL) + { + setting->second.setting = *settingIt; + (*settingIt)->m_callback = this; + } + } + } + } + } + else + { + CLog::Log(LOGWARNING, "CSettingsManager: unable to read section \"%s\"", sectionId.c_str()); + if (!update) + delete section; + } + } + + sectionNode = sectionNode->NextSibling(XML_SECTION); + } + + for (SettingMap::iterator itSettingDep = m_settings.begin(); itSettingDep != m_settings.end(); itSettingDep++) + { + if (itSettingDep->second.setting == NULL) + continue; + + const SettingDependencies& deps = itSettingDep->second.setting->GetDependencies(); + for (SettingDependencies::const_iterator depIt = deps.begin(); depIt != deps.end(); depIt++) + { + std::set settingIds = depIt->GetSettings(); + for (std::set::const_iterator itSettingId = settingIds.begin(); itSettingId != settingIds.end(); itSettingId++) + { + SettingMap::iterator setting = m_settings.find(*itSettingId); + if (setting == m_settings.end()) + continue; + + setting->second.dependencies[itSettingDep->first].push_back(*depIt); + } + } + } + + return true; +} + +bool CSettingsManager::Load(const TiXmlElement *root, bool &updated, bool triggerEvents /* = true */, std::map *loadedSettings /* = NULL */) +{ + CSingleLock lock(m_critical); + if (m_loaded || root == NULL) + return false; + + if (triggerEvents && !OnSettingsLoading()) + return false; + + if (!Deserialize(root, loadedSettings)) + return false; + + bool ret = true; + // load any ISubSettings implementations + if (triggerEvents) + ret = Load(root); + + updated = UpdateSettings(root); + + if (triggerEvents) + OnSettingsLoaded(); + + return ret; +} + +bool CSettingsManager::Save(TiXmlNode *root) const +{ + CSingleLock lock(m_critical); + if (!m_initialized || root == NULL) + return false; + + if (!OnSettingsSaving()) + return false; + + if (!Serialize(root)) + { + CLog::Log(LOGERROR, "CSettingsManager: failed to save settings"); + return false; + } + + // save any ISubSettings implementations + for (std::set::const_iterator it = m_subSettings.begin(); it != m_subSettings.end(); it++) + { + if (!(*it)->Save(root)) + return false; + } + + OnSettingsSaved(); + + return true; +} + +void CSettingsManager::Unload() +{ + CSingleLock lock(m_critical); + m_loaded = false; + for (SettingMap::iterator setting = m_settings.begin(); setting != m_settings.end(); setting++) + setting->second.setting->Reset(); +} + +void CSettingsManager::Clear() +{ + CSingleLock lock(m_critical); + m_settings.clear(); + for (SettingSectionMap::iterator section = m_sections.begin(); section != m_sections.end(); section++) + delete section->second; + m_sections.clear(); + + OnSettingsCleared(); + + for (std::set::const_iterator it = m_subSettings.begin(); it != m_subSettings.end(); it++) + (*it)->Clear(); + + m_loaded = false; + m_initialized = false; +} + +bool CSettingsManager::LoadSetting(const TiXmlNode *node, const std::string &settingId) +{ + if (node == NULL) + return false; + + CSetting *setting = GetSetting(settingId); + if (setting == NULL) + return false; + + return LoadSetting(node, setting); +} + +void CSettingsManager::SetInitialized() +{ + CSingleLock lock(m_critical); + if (m_initialized) + return; + + m_initialized = true; + + for (SettingMap::iterator setting = m_settings.begin(); setting != m_settings.end(); ) + { + SettingMap::iterator tmpIterator = setting++; + if (tmpIterator->second.setting == NULL) + m_settings.erase(tmpIterator); + } +} + +void CSettingsManager::RegisterCallback(ISettingCallback *callback, const std::set &settingList) +{ + CSingleLock lock(m_critical); + if (callback == NULL) + return; + + for (std::set::const_iterator settingIt = settingList.begin(); settingIt != settingList.end(); settingIt++) + { + std::string id = *settingIt; + StringUtils::ToLower(id); + + SettingMap::iterator setting = m_settings.find(id); + if (setting == m_settings.end()) + { + if (m_initialized) + continue; + + Setting tmpSetting = { NULL }; + std::pair tmpIt = m_settings.insert(make_pair(id, tmpSetting)); + setting = tmpIt.first; + } + + setting->second.callbacks.insert(callback); + } +} + +void CSettingsManager::UnregisterCallback(ISettingCallback *callback) +{ + CSingleLock lock(m_critical); + for (SettingMap::iterator settingIt = m_settings.begin(); settingIt != m_settings.end(); settingIt++) + settingIt->second.callbacks.erase(callback); +} + +void CSettingsManager::RegisterSettingType(const std::string &settingType, ISettingCreator *settingCreator) +{ + CSingleLock lock(m_critical); + if (settingType.empty() || settingCreator == NULL) + return; + + SettingCreatorMap::const_iterator creatorIt = m_settingCreators.find(settingType); + if (creatorIt == m_settingCreators.end()) + m_settingCreators.insert(make_pair(settingType, settingCreator)); +} + +void CSettingsManager::RegisterSettingsHandler(ISettingsHandler *settingsHandler) +{ + if (settingsHandler == NULL) + return; + + CSingleLock lock(m_critical); + m_settingsHandlers.insert(settingsHandler); +} + +void CSettingsManager::UnregisterSettingsHandler(ISettingsHandler *settingsHandler) +{ + if (settingsHandler == NULL) + return; + + CSingleLock lock(m_critical); + m_settingsHandlers.erase(settingsHandler); +} + +void CSettingsManager::RegisterSubSettings(ISubSettings *subSettings) +{ + CSingleLock lock(m_critical); + if (subSettings == NULL) + return; + + m_subSettings.insert(subSettings); +} + +void CSettingsManager::UnregisterSubSettings(ISubSettings *subSettings) +{ + CSingleLock lock(m_critical); + if (subSettings == NULL) + return; + + m_subSettings.erase(subSettings); +} + +void CSettingsManager::RegisterSettingOptionsFiller(const std::string &identifier, IntegerSettingOptionsFiller optionsFiller) +{ + if (identifier.empty() || optionsFiller == NULL) + return; + + RegisterSettingOptionsFiller(identifier, (void*)optionsFiller, SettingOptionsFillerTypeInteger); +} + +void CSettingsManager::RegisterSettingOptionsFiller(const std::string &identifier, StringSettingOptionsFiller optionsFiller) +{ + if (identifier.empty() || optionsFiller == NULL) + return; + + RegisterSettingOptionsFiller(identifier, (void*)optionsFiller, SettingOptionsFillerTypeString); +} + +void CSettingsManager::UnregisterSettingOptionsFiller(const std::string &identifier) +{ + m_optionsFillers.erase(identifier); +} + +void* CSettingsManager::GetSettingOptionsFiller(const CSetting *setting) +{ + if (setting == NULL) + return NULL; + + // get the option filler's identifier + std::string filler; + if (setting->GetType() == SettingTypeInteger) + filler = ((const CSettingInt*)setting)->GetOptionsFiller(); + else if (setting->GetType() == SettingTypeString) + filler = ((const CSettingString*)setting)->GetOptionsFiller(); + + if (filler.empty()) + return NULL; + + // check if such an option filler is known + SettingOptionsFillerMap::const_iterator fillerIt = m_optionsFillers.find(filler); + if (fillerIt == m_optionsFillers.end()) + return NULL; + + if (fillerIt->second.filler == NULL) + return NULL; + + // make sure the option filler's type matches the setting's type + switch (fillerIt->second.type) + { + case SettingOptionsFillerTypeInteger: + { + if (setting->GetType() != SettingTypeInteger) + return NULL; + + break; + } + + case SettingOptionsFillerTypeString: + { + if (setting->GetType() != SettingTypeString) + return NULL; + + break; + } + + default: + return NULL; + } + + return fillerIt->second.filler; +} + +CSetting* CSettingsManager::GetSetting(const std::string &id) const +{ + CSingleLock lock(m_critical); + if (id.empty()) + return NULL; + + std::string settingId = id; + StringUtils::ToLower(settingId); + + SettingMap::const_iterator setting = m_settings.find(settingId); + if (setting != m_settings.end()) + return setting->second.setting; + + CLog::Log(LOGDEBUG, "CSettingsManager: requested setting (%s) was not found.", id.c_str()); + return NULL; +} + +CSettingSection* CSettingsManager::GetSection(const std::string §ion) const +{ + CSingleLock lock(m_critical); + if (section.empty()) + return NULL; + + std::string sectionId = section; + StringUtils::ToLower(sectionId); + + SettingSectionMap::const_iterator sectionIt = m_sections.find(sectionId); + if (sectionIt != m_sections.end()) + return sectionIt->second; + + CLog::Log(LOGDEBUG, "CSettingsManager: requested setting section (%s) was not found.", section.c_str()); + return NULL; +} + +SettingDependencyMap CSettingsManager::GetDependencies(const std::string &id) const +{ + CSingleLock lock(m_critical); + SettingMap::const_iterator setting = m_settings.find(id); + if (setting == m_settings.end()) + return SettingDependencyMap(); + + return setting->second.dependencies; +} + +SettingDependencyMap CSettingsManager::GetDependencies(const CSetting *setting) const +{ + CSingleLock lock(m_critical); + if (setting == NULL) + return SettingDependencyMap(); + + return GetDependencies(setting->GetId()); +} + +bool CSettingsManager::GetBool(const std::string &id) const +{ + CSingleLock lock(m_critical); + CSetting *setting = GetSetting(id); + if (setting == NULL || setting->GetType() != SettingTypeBool) + { + // Backward compatibility (skins use this setting) + if (setting == NULL && StringUtils::EqualsNoCase(id.c_str(), "lookandfeel.enablemouse")) + return GetBool("input.enablemouse"); + + return false; + } + + return ((CSettingBool*)setting)->GetValue(); +} + +bool CSettingsManager::SetBool(const std::string &id, bool value) +{ + CSingleLock lock(m_critical); + CSetting *setting = GetSetting(id); + if (setting == NULL || setting->GetType() != SettingTypeBool) + return false; + + return ((CSettingBool*)setting)->SetValue(value); +} + +bool CSettingsManager::ToggleBool(const std::string &id) +{ + CSingleLock lock(m_critical); + CSetting *setting = GetSetting(id); + if (setting == NULL || setting->GetType() != SettingTypeBool) + return false; + + return SetBool(id, !((CSettingBool*)setting)->GetValue()); +} + +int CSettingsManager::GetInt(const std::string &id) const +{ + CSingleLock lock(m_critical); + CSetting *setting = GetSetting(id); + if (setting == NULL || setting->GetType() != SettingTypeInteger) + return 0; + + return ((CSettingInt*)setting)->GetValue(); +} + +bool CSettingsManager::SetInt(const std::string &id, int value) +{ + CSingleLock lock(m_critical); + CSetting *setting = GetSetting(id); + if (setting == NULL || setting->GetType() != SettingTypeInteger) + return false; + + return ((CSettingInt*)setting)->SetValue(value); +} + +double CSettingsManager::GetNumber(const std::string &id) const +{ + CSingleLock lock(m_critical); + CSetting *setting = GetSetting(id); + if (setting == NULL || setting->GetType() != SettingTypeNumber) + return 0.0; + + return ((CSettingNumber*)setting)->GetValue(); +} + +bool CSettingsManager::SetNumber(const std::string &id, double value) +{ + CSingleLock lock(m_critical); + CSetting *setting = GetSetting(id); + if (setting == NULL || setting->GetType() != SettingTypeNumber) + return false; + + return ((CSettingNumber*)setting)->SetValue(value); +} + +std::string CSettingsManager::GetString(const std::string &id) const +{ + CSingleLock lock(m_critical); + CSetting *setting = GetSetting(id); + if (setting == NULL || setting->GetType() != SettingTypeString) + return ""; + + return ((CSettingString*)setting)->GetValue(); +} + +bool CSettingsManager::SetString(const std::string &id, const std::string &value) +{ + CSingleLock lock(m_critical); + CSetting *setting = GetSetting(id); + if (setting == NULL || setting->GetType() != SettingTypeString) + return false; + + return ((CSettingString*)setting)->SetValue(value); +} + +void CSettingsManager::AddCondition(const std::string &condition) +{ + if (condition.empty()) + return; + + m_conditions.AddCondition(condition); +} + +void CSettingsManager::AddCondition(const std::string &identifier, SettingConditionCheck condition) +{ + if (identifier.empty() || condition == NULL) + return; + + m_conditions.AddCondition(identifier, condition); +} + +bool CSettingsManager::Serialize(TiXmlNode *parent) const +{ + if (parent == NULL) + return false; + + for (SettingMap::const_iterator it = m_settings.begin(); it != m_settings.end(); it++) + { + if (it->second.setting->GetType() == SettingTypeAction) + continue; + + std::vector parts = StringUtils::Split(it->first, "."); + if (parts.size() != 2 || parts.at(0).empty() || parts.at(1).empty()) + { + CLog::Log(LOGWARNING, "CSettingsManager: unable to save setting \"%s\"", it->first.c_str()); + continue; + } + + TiXmlNode *sectionNode = parent->FirstChild(parts.at(0)); + if (sectionNode == NULL) + { + TiXmlElement sectionElement(parts.at(0)); + sectionNode = parent->InsertEndChild(sectionElement); + + if (sectionNode == NULL) + { + CLog::Log(LOGWARNING, "CSettingsManager: unable to write <%s> tag", parts.at(0).c_str()); + continue; + } + } + + TiXmlElement settingElement(parts.at(1)); + TiXmlNode *settingNode = sectionNode->InsertEndChild(settingElement); + if (settingNode == NULL) + { + CLog::Log(LOGWARNING, "CSetting: unable to write <%s> tag in <%s>", parts.at(1).c_str(), parts.at(0).c_str()); + continue; + } + + TiXmlText value(it->second.setting->ToString()); + settingNode->InsertEndChild(value); + } + + return true; +} + +bool CSettingsManager::Deserialize(const TiXmlNode *node, std::map *loadedSettings /* = NULL */) +{ + if (node == NULL) + return false; + + for (SettingMap::iterator it = m_settings.begin(); it != m_settings.end(); it++) + { + if (LoadSetting(node, it->second.setting) && loadedSettings != NULL) + loadedSettings->insert(make_pair(it->first, it->second.setting)); + } + + return true; +} + +bool CSettingsManager::OnSettingChanging(const CSetting *setting) +{ + CSingleLock lock(m_critical); + if (setting == NULL) + return false; + + if (!m_loaded) + return true; + + SettingMap::const_iterator settingIt = m_settings.find(setting->GetId()); + if (settingIt == m_settings.end()) + return false; + + Setting settingData = settingIt->second; + // now that we have a copy of the setting's data, we can leave the lock + lock.Leave(); + + for (CallbackSet::iterator callback = settingData.callbacks.begin(); + callback != settingData.callbacks.end(); + callback++) + { + if (!(*callback)->OnSettingChanging(setting)) + return false; + } + + return true; +} + +void CSettingsManager::OnSettingChanged(const CSetting *setting) +{ + CSingleLock lock(m_critical); + if (!m_loaded || setting == NULL) + return; + + SettingMap::const_iterator settingIt = m_settings.find(setting->GetId()); + if (settingIt == m_settings.end()) + return; + + Setting settingData = settingIt->second; + // now that we have a copy of the setting's data, we can leave the lock + lock.Leave(); + + for (CallbackSet::iterator callback = settingData.callbacks.begin(); + callback != settingData.callbacks.end(); + callback++) + (*callback)->OnSettingChanged(setting); +} + +void CSettingsManager::OnSettingAction(const CSetting *setting) +{ + CSingleLock lock(m_critical); + if (!m_loaded || setting == NULL) + return; + + SettingMap::const_iterator settingIt = m_settings.find(setting->GetId()); + if (settingIt == m_settings.end()) + return; + + Setting settingData = settingIt->second; + // now that we have a copy of the setting's data, we can leave the lock + lock.Leave(); + + for (CallbackSet::iterator callback = settingData.callbacks.begin(); + callback != settingData.callbacks.end(); + callback++) + (*callback)->OnSettingAction(setting); +} + +bool CSettingsManager::OnSettingUpdate(CSetting* &setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) +{ + CSingleLock lock(m_critical); + if (setting == NULL) + return false; + + SettingMap::const_iterator settingIt = m_settings.find(setting->GetId()); + if (settingIt == m_settings.end()) + return false; + + Setting settingData = settingIt->second; + // now that we have a copy of the setting's data, we can leave the lock + lock.Leave(); + + bool ret = false; + for (CallbackSet::iterator callback = settingData.callbacks.begin(); + callback != settingData.callbacks.end(); + callback++) + ret |= (*callback)->OnSettingUpdate(setting, oldSettingId, oldSettingNode); + + return ret; +} + +CSetting* CSettingsManager::CreateSetting(const std::string &settingType, const std::string &settingId, CSettingsManager *settingsManager /* = NULL */) const +{ + if (StringUtils::EqualsNoCase(settingType, "boolean")) + return new CSettingBool(settingId, (CSettingsManager*)this); + else if (StringUtils::EqualsNoCase(settingType, "integer")) + return new CSettingInt(settingId, (CSettingsManager*)this); + else if (StringUtils::EqualsNoCase(settingType, "number")) + return new CSettingNumber(settingId, (CSettingsManager*)this); + else if (StringUtils::EqualsNoCase(settingType, "string")) + return new CSettingString(settingId, (CSettingsManager*)this); + else if (StringUtils::EqualsNoCase(settingType, "action")) + return new CSettingAction(settingId, (CSettingsManager*)this); + + SettingCreatorMap::const_iterator creator = m_settingCreators.find(settingType); + if (creator != m_settingCreators.end()) + return creator->second->CreateSetting(settingType, settingId, (CSettingsManager*)this); + + return NULL; +} + +bool CSettingsManager::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 CSettingsManager::OnSettingsLoaded() +{ + CSingleLock lock(m_critical); + for (SettingsHandlers::const_iterator it = m_settingsHandlers.begin(); it != m_settingsHandlers.end(); it++) + (*it)->OnSettingsLoaded(); +} + +bool CSettingsManager::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 CSettingsManager::OnSettingsSaved() const +{ + CSingleLock lock(m_critical); + for (SettingsHandlers::const_iterator it = m_settingsHandlers.begin(); it != m_settingsHandlers.end(); it++) + (*it)->OnSettingsSaved(); +} + +void CSettingsManager::OnSettingsCleared() +{ + CSingleLock lock(m_critical); + for (SettingsHandlers::const_iterator it = m_settingsHandlers.begin(); it != m_settingsHandlers.end(); it++) + (*it)->OnSettingsCleared(); +} + +bool CSettingsManager::Load(const TiXmlNode *settings) +{ + bool ok = true; + for (std::set::const_iterator it = m_subSettings.begin(); it != m_subSettings.end(); it++) + ok &= (*it)->Load(settings); + + return ok; +} + +bool CSettingsManager::LoadSetting(const TiXmlNode *node, CSetting *setting) +{ + if (node == NULL || setting == NULL) + return false; + + if (setting->GetType() == SettingTypeAction) + return false; + + const std::string &settingId = setting->GetId(); + + std::vector parts = StringUtils::Split(settingId, "."); + if (parts.size() != 2 || parts.at(0).empty() || parts.at(1).empty()) + { + CLog::Log(LOGWARNING, "CSettingsManager: unable to load setting \"%s\"", settingId.c_str()); + return false; + } + + const TiXmlNode *sectionNode = node->FirstChild(parts.at(0)); + if (sectionNode == NULL) + return false; + + const TiXmlNode *settingNode = sectionNode->FirstChild(parts.at(1)); + if (settingNode == NULL) + return false; + + if (!setting->FromString(settingNode->FirstChild() != NULL ? settingNode->FirstChild()->ValueStr() : StringUtils::Empty)) + { + CLog::Log(LOGWARNING, "CSettingsManager: unable to read value of setting \"%s\"", settingId.c_str()); + return false; + } + + return true; +} + +bool CSettingsManager::UpdateSettings(const TiXmlNode *root) +{ + bool updated = false; + + for (SettingMap::iterator setting = m_settings.begin(); setting != m_settings.end(); setting++) + { + const std::set& updates = setting->second.setting->GetUpdates(); + if (updates.empty()) + continue; + + for (std::set::const_iterator update = updates.begin(); update != updates.end(); update++) + updated |= UpdateSetting(root, setting->second.setting, *update); + } + + return updated; +} + +bool CSettingsManager::UpdateSetting(const TiXmlNode *node, CSetting *setting, const CSettingUpdate& update) +{ + if (node == NULL || setting == NULL || update.GetType() == SettingUpdateTypeNone) + return false; + + bool updated = false; + const char *oldSetting = NULL; + const TiXmlNode *oldSettingNode = NULL; + if (update.GetType() == SettingUpdateTypeRename) + { + if (update.GetValue().empty()) + return false; + + oldSetting = update.GetValue().c_str(); + std::vector parts = StringUtils::Split(oldSetting, "."); + if (parts.size() != 2 || parts.at(0).empty() || parts.at(1).empty()) + return false; + + const TiXmlNode *sectionNode = node->FirstChild(parts.at(0)); + if (sectionNode == NULL) + return false; + + oldSettingNode = sectionNode->FirstChild(parts.at(1)); + if (oldSettingNode == NULL) + return false; + + if (setting->FromString(oldSettingNode->FirstChild() != NULL ? oldSettingNode->FirstChild()->ValueStr() : StringUtils::Empty)) + updated = true; + else + CLog::Log(LOGWARNING, "CSetting: unable to update \"%s\" through automatically renaming from \"%s\"", setting->GetId().c_str(), oldSetting); + } + + updated |= OnSettingUpdate(setting, oldSetting, oldSettingNode); + return updated; +} + +void CSettingsManager::RegisterSettingOptionsFiller(const std::string &identifier, void *filler, SettingOptionsFillerType type) +{ + SettingOptionsFillerMap::const_iterator it = m_optionsFillers.find(identifier); + if (it != m_optionsFillers.end()) + return; + + SettingOptionsFiller optionsFiller = { filler, type }; + m_optionsFillers.insert(make_pair(identifier, optionsFiller)); +} diff --git a/xbmc/settings/SettingsManager.h b/xbmc/settings/SettingsManager.h new file mode 100644 index 0000000000000..13a6c98b66d2b --- /dev/null +++ b/xbmc/settings/SettingsManager.h @@ -0,0 +1,169 @@ +#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 + * . + * + */ + +#include +#include +#include + +#include "ISetting.h" +#include "ISettingCallback.h" +#include "ISettingCreator.h" +#include "ISettingsHandler.h" +#include "ISubSettings.h" +#include "SettingConditions.h" +#include "SettingDependency.h" +#include "threads/CriticalSection.h" + +class CSettingSection; +class CSettingUpdate; + +class TiXmlElement; +class TiXmlNode; + +typedef std::pair IntegerSettingOption; +typedef std::pair StringSettingOption; +typedef std::vector IntegerSettingOptions; +typedef std::vector StringSettingOptions; +typedef void (*IntegerSettingOptionsFiller)(const CSetting *setting, IntegerSettingOptions &list, int ¤t); +typedef void (*StringSettingOptionsFiller)(const CSetting *setting, StringSettingOptions &list, std::string ¤t); + +class CSettingsManager : public ISettingCreator, private ISettingCallback, + private ISettingsHandler, private ISubSettings +{ +public: + CSettingsManager(); + virtual ~CSettingsManager(); + + // implementation of ISettingCreator + virtual CSetting* CreateSetting(const std::string &settingType, const std::string &settingId, CSettingsManager *settingsManager = NULL) const; + + bool Initialize(const TiXmlElement *root); + bool Load(const TiXmlElement *root, bool &updated, bool triggerEvents = true, std::map *loadedSettings = NULL); + virtual bool Save(TiXmlNode *root) const; + void Unload(); + void Clear(); + + bool LoadSetting(const TiXmlNode *node, const std::string &settingId); + + void SetInitialized(); + void SetLoaded() { m_loaded = true; } + + void RegisterCallback(ISettingCallback *callback, const std::set &settingList); + void UnregisterCallback(ISettingCallback *callback); + + void RegisterSettingType(const std::string &settingType, ISettingCreator *settingCreator); + + void RegisterSettingsHandler(ISettingsHandler *settingsHandler); + void UnregisterSettingsHandler(ISettingsHandler *settingsHandler); + + void RegisterSubSettings(ISubSettings *subSettings); + void UnregisterSubSettings(ISubSettings *subSettings); + + void RegisterSettingOptionsFiller(const std::string &identifier, IntegerSettingOptionsFiller optionsFiller); + void RegisterSettingOptionsFiller(const std::string &identifier, StringSettingOptionsFiller optionsFiller); + void UnregisterSettingOptionsFiller(const std::string &identifier); + void* GetSettingOptionsFiller(const CSetting *setting); + + CSetting* GetSetting(const std::string &id) const; + CSettingSection* GetSection(const std::string §ion) const; + SettingDependencyMap GetDependencies(const std::string &id) const; + SettingDependencyMap GetDependencies(const CSetting *setting) const; + + bool GetBool(const std::string &id) const; + int GetInt(const std::string &id) const; + double GetNumber(const std::string &id) const; + std::string GetString(const std::string &id) const; + + bool SetBool(const std::string &id, bool value); + bool ToggleBool(const std::string &id); + bool SetInt(const std::string &id, int value); + bool SetNumber(const std::string &id, double value); + bool SetString(const std::string &id, const std::string &value); + + const CSettingConditionsManager& GetConditions() const { return m_conditions; } + void AddCondition(const std::string &condition); + void AddCondition(const std::string &identifier, SettingConditionCheck condition); + +private: + // implementation of ISettingCallback + virtual bool OnSettingChanging(const CSetting *setting); + virtual void OnSettingChanged(const CSetting *setting); + virtual void OnSettingAction(const CSetting *setting); + virtual bool OnSettingUpdate(CSetting* &setting, const char *oldSettingId, const TiXmlNode *oldSettingNode); + + // 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); + + bool Serialize(TiXmlNode *parent) const; + bool Deserialize(const TiXmlNode *node, std::map *loadedSettings = NULL); + + bool LoadSetting(const TiXmlNode *node, CSetting *setting); + bool UpdateSettings(const TiXmlNode *root); + bool UpdateSetting(const TiXmlNode *node, CSetting *setting, const CSettingUpdate& update); + + typedef enum { + SettingOptionsFillerTypeNone = 0, + SettingOptionsFillerTypeInteger, + SettingOptionsFillerTypeString + } SettingOptionsFillerType; + + void RegisterSettingOptionsFiller(const std::string &identifier, void *filler, SettingOptionsFillerType type); + + typedef std::set CallbackSet; + typedef struct { + CSetting *setting; + SettingDependencyMap dependencies; + CallbackSet callbacks; + } Setting; + + bool m_initialized; + bool m_loaded; + + typedef std::map SettingMap; + SettingMap m_settings; + typedef std::map SettingSectionMap; + SettingSectionMap m_sections; + + typedef std::map SettingCreatorMap; + SettingCreatorMap m_settingCreators; + + std::set m_subSettings; + typedef std::set SettingsHandlers; + SettingsHandlers m_settingsHandlers; + + CSettingConditionsManager m_conditions; + + typedef struct { + void *filler; + SettingOptionsFillerType type; + } SettingOptionsFiller; + typedef std::map SettingOptionsFillerMap; + SettingOptionsFillerMap m_optionsFillers; + + CCriticalSection m_critical; +}; diff --git a/xbmc/settings/SkinSettings.cpp b/xbmc/settings/SkinSettings.cpp index 0d9044eabfabe..bc665edc73df9 100644 --- a/xbmc/settings/SkinSettings.cpp +++ b/xbmc/settings/SkinSettings.cpp @@ -22,7 +22,7 @@ #include "SkinSettings.h" #include "GUIInfoManager.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "threads/SingleLock.h" #include "utils/log.h" #include "utils/StringUtils.h" @@ -277,5 +277,5 @@ void CSkinSettings::Clear() std::string CSkinSettings::GetCurrentSkin() const { - return g_guiSettings.GetString("lookandfeel.skin"); + return CSettings::Get().GetString("lookandfeel.skin"); } \ No newline at end of file diff --git a/xbmc/settings/dialogs/GUIDialogContentSettings.cpp b/xbmc/settings/dialogs/GUIDialogContentSettings.cpp index d68d25e7d5ebd..fd5a86fcd0219 100644 --- a/xbmc/settings/dialogs/GUIDialogContentSettings.cpp +++ b/xbmc/settings/dialogs/GUIDialogContentSettings.cpp @@ -20,7 +20,6 @@ #include "GUIDialogContentSettings.h" #include "addons/GUIDialogAddonSettings.h" -#include "settings/GUISettings.h" #include "guilib/GUIWindowManager.h" #include "guilib/Key.h" #include "addons/IAddon.h" diff --git a/xbmc/settings/dialogs/GUIDialogSettings.cpp b/xbmc/settings/dialogs/GUIDialogSettings.cpp index ce737e5e461ad..708de2417ec65 100644 --- a/xbmc/settings/dialogs/GUIDialogSettings.cpp +++ b/xbmc/settings/dialogs/GUIDialogSettings.cpp @@ -26,7 +26,6 @@ #include "guilib/GUIImage.h" #include "guilib/GUIControlGroupList.h" #include "guilib/LocalizeStrings.h" -#include "settings/GUISettings.h" #include "utils/log.h" #include "guilib/GUIKeyboardFactory.h" diff --git a/xbmc/settings/windows/GUIControlSettings.cpp b/xbmc/settings/windows/GUIControlSettings.cpp new file mode 100644 index 0000000000000..7313b49cd40ba --- /dev/null +++ b/xbmc/settings/windows/GUIControlSettings.cpp @@ -0,0 +1,396 @@ +/* + * Copyright (C) 2005-2012 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 + * . + * + */ + +#include "GUIControlSettings.h" +#include "Util.h" +#include "addons/AddonManager.h" +#include "addons/GUIWindowAddonBrowser.h" +#include "dialogs/GUIDialogFileBrowser.h" +#include "dialogs/GUIDialogOK.h" +#include "guilib/GUIEditControl.h" +#include "guilib/GUIImage.h" +#include "guilib/GUIRadioButtonControl.h" +#include "guilib/GUISpinControlEx.h" +#include "guilib/LocalizeStrings.h" +#include "settings/SettingAddon.h" +#include "settings/SettingPath.h" +#include "settings/Settings.h" +#include "settings/MediaSourceSettings.h" +#include "settings/Setting.h" +#include "storage/MediaManager.h" +#include "utils/StringUtils.h" + +using namespace ADDON; + +CGUIControlBaseSetting::CGUIControlBaseSetting(int id, CSetting *pSetting) +{ + m_id = id; + m_pSetting = pSetting; + m_delayed = false; + m_enabled = true; +} + +void CGUIControlBaseSetting::Update() +{ + CGUIControl *control = GetControl(); + if (control != NULL) + control->SetEnabled(IsEnabled()); +} + +CGUIControlRadioButtonSetting::CGUIControlRadioButtonSetting(CGUIRadioButtonControl *pRadioButton, int id, CSetting *pSetting) + : CGUIControlBaseSetting(id, pSetting) +{ + m_pRadioButton = pRadioButton; + m_pRadioButton->SetID(id); + Update(); +} + +CGUIControlRadioButtonSetting::~CGUIControlRadioButtonSetting() +{ } + +bool CGUIControlRadioButtonSetting::OnClick() +{ + return ((CSettingBool *)m_pSetting)->SetValue(!((CSettingBool *)m_pSetting)->GetValue()); +} + +void CGUIControlRadioButtonSetting::Update() +{ + if (m_pRadioButton == NULL) + return; + + CGUIControlBaseSetting::Update(); + + m_pRadioButton->SetSelected(((CSettingBool *)m_pSetting)->GetValue()); +} + +CGUIControlSpinExSetting::CGUIControlSpinExSetting(CGUISpinControlEx *pSpin, int id, CSetting *pSetting) + : CGUIControlBaseSetting(id, pSetting) +{ + m_pSpin = pSpin; + m_pSpin->SetID(id); + + switch (pSetting->GetControl().GetFormat()) + { + case SettingControlFormatNumber: + { + CSettingNumber *pSettingNumber = (CSettingNumber *)pSetting; + m_pSpin->SetType(SPIN_CONTROL_TYPE_FLOAT); + m_pSpin->SetFloatRange((float)pSettingNumber->GetMinimum(), (float)pSettingNumber->GetMaximum()); + m_pSpin->SetFloatInterval((float)pSettingNumber->GetStep()); + break; + } + + case SettingControlFormatInteger: + case SettingControlFormatString: + { + m_pSpin->SetType(SPIN_CONTROL_TYPE_TEXT); + m_pSpin->Clear(); + + if (pSetting->GetType() == SettingTypeInteger) + { + CSettingInt *pSettingInt = (CSettingInt *)pSetting; + + const SettingOptions& options = pSettingInt->GetOptions(); + if (!options.empty()) + { + for (SettingOptions::const_iterator it = options.begin(); it != options.end(); it++) + m_pSpin->AddLabel(g_localizeStrings.Get(it->first), it->second); + m_pSpin->SetValue(pSettingInt->GetValue()); + } + else + { + std::string strLabel; + int i = pSettingInt->GetMinimum(); + if (pSettingInt->GetMinimumLabel() > -1) + { + strLabel = g_localizeStrings.Get(pSettingInt->GetMinimumLabel()); + m_pSpin->AddLabel(strLabel, pSettingInt->GetMinimum()); + i += pSettingInt->GetStep(); + } + for (; i <= pSettingInt->GetMaximum(); i += pSettingInt->GetStep()) + { + if (pSettingInt->GetFormat() > -1) + strLabel = StringUtils::Format(g_localizeStrings.Get(pSettingInt->GetFormat()).c_str(), i); + else + strLabel = StringUtils::Format(pSettingInt->GetFormatString().c_str(), i); + m_pSpin->AddLabel(strLabel, i); + } + } + } + break; + } + + default: + break; + } +} + +CGUIControlSpinExSetting::~CGUIControlSpinExSetting() +{ } + +bool CGUIControlSpinExSetting::OnClick() +{ + if (m_pSpin == NULL) + return false; + + switch (m_pSetting->GetType()) + { + case SettingTypeInteger: + return ((CSettingInt *)m_pSetting)->SetValue(m_pSpin->GetValue()); + break; + + case SettingTypeNumber: + return ((CSettingNumber *)m_pSetting)->SetValue(m_pSpin->GetFloatValue()); + + case SettingTypeString: + return ((CSettingString *)m_pSetting)->SetValue(m_pSpin->GetStringValue()); + + default: + break; + } + + return false; +} + +void CGUIControlSpinExSetting::Update() +{ + if (m_pSpin == NULL) + return; + + CGUIControlBaseSetting::Update(); + + switch (m_pSetting->GetType()) + { + case SettingTypeInteger: + m_pSpin->SetValue(((CSettingInt *)m_pSetting)->GetValue()); + break; + + case SettingTypeNumber: + m_pSpin->SetFloatValue((float)((CSettingNumber *)m_pSetting)->GetValue()); + break; + + case SettingTypeString: + m_pSpin->SetStringValue(((CSettingString *)m_pSetting)->GetValue()); + break; + + default: + break; + } + + // disable the spinner if it has less than two items + if (!m_pSpin->IsDisabled() && (m_pSpin->GetMaximum() - m_pSpin->GetMinimum()) == 0) + m_pSpin->SetEnabled(false); +} + +CGUIControlButtonSetting::CGUIControlButtonSetting(CGUIButtonControl *pButton, int id, CSetting *pSetting) + : CGUIControlBaseSetting(id, pSetting) +{ + m_pButton = pButton; + m_pButton->SetID(id); + Update(); +} + +CGUIControlButtonSetting::~CGUIControlButtonSetting() +{ } + +bool CGUIControlButtonSetting::OnClick() +{ + if (m_pButton == NULL) + return false; + + bool success = false; + switch (m_pSetting->GetControl().GetFormat()) + { + case SettingControlFormatAddon: + { + // prompt for the addon + CSettingAddon *setting = (CSettingAddon *)m_pSetting; + CStdString addonID = setting->GetValue(); + if (!CGUIWindowAddonBrowser::SelectAddonID(setting->GetAddonType(), addonID, setting->AllowEmpty()) == 1) + return false; + + success = setting->SetValue(addonID); + break; + } + + case SettingControlFormatPath: + { + success = GetPath((CSettingPath *)m_pSetting); + break; + } + + case SettingControlFormatAction: + { + // simply call the OnSettingAction callback and whoever knows what to + // do can do so (based on the setting's identification + CSettingAction *pSettingAction = (CSettingAction *)m_pSetting; + pSettingAction->OnSettingAction(pSettingAction); + success = true; + break; + } + + default: + return false; + } + + return success; +} + +void CGUIControlButtonSetting::Update() +{ + if (m_pButton == NULL) + return; + + CGUIControlBaseSetting::Update(); + + if (m_pSetting->GetType() == SettingTypeString) + { + std::string strText = ((CSettingString *)m_pSetting)->GetValue(); + switch (m_pSetting->GetControl().GetFormat()) + { + case SettingControlFormatAddon: + { + ADDON::AddonPtr addon; + if (ADDON::CAddonMgr::Get().GetAddon(strText, addon)) + strText = addon->Name(); + if (strText.empty()) + strText = g_localizeStrings.Get(231); // None + break; + } + + case SettingControlFormatPath: + { + CStdString shortPath; + if (CUtil::MakeShortenPath(strText, shortPath, 30)) + strText = shortPath; + break; + } + + default: + return; + } + + m_pButton->SetLabel2(strText); + } +} + +bool CGUIControlButtonSetting::GetPath(CSettingPath *pathSetting) +{ + if (pathSetting == NULL) + return false; + + CStdString path = pathSetting->GetValue(); + + VECSOURCES shares; + const std::vector& sources = pathSetting->GetSources(); + for (std::vector::const_iterator source = sources.begin(); source != sources.end(); source++) + { + VECSOURCES *sources = CMediaSourceSettings::Get().GetSources(*source); + if (sources != NULL) + shares.insert(shares.end(), sources->begin(), sources->end()); + } + + g_mediaManager.GetNetworkLocations(shares); + g_mediaManager.GetLocalDrives(shares); + + if (!CGUIDialogFileBrowser::ShowAndGetDirectory(shares, g_localizeStrings.Get(pathSetting->GetHeading()), path, pathSetting->Writable())) + return false; + + return pathSetting->SetValue(path); +} + +CGUIControlEditSetting::CGUIControlEditSetting(CGUIEditControl *pEdit, int id, CSetting *pSetting) + : CGUIControlBaseSetting(id, pSetting) +{ + m_pEdit = pEdit; + m_pEdit->SetID(id); + int heading = m_pSetting->GetLabel(); + if (m_pSetting->GetType() == SettingTypeString) + { + CSettingString *pSettingString = (CSettingString *)m_pSetting; + if (pSettingString->GetHeading() > 0) + heading = pSettingString->GetHeading(); + } + if (heading < 0) + heading = 0; + + CGUIEditControl::INPUT_TYPE inputType = CGUIEditControl::INPUT_TYPE_TEXT; + const CSettingControl& control = pSetting->GetControl(); + switch (control.GetFormat()) + { + case SettingControlFormatString: + if (control.GetAttributes() & SettingControlAttributeHidden) + inputType = CGUIEditControl::INPUT_TYPE_PASSWORD; + break; + + case SettingControlFormatInteger: + if (control.GetAttributes() & SettingControlAttributeVerifyNew) + inputType = CGUIEditControl::INPUT_TYPE_PASSWORD_NUMBER_VERIFY_NEW; + else + inputType = CGUIEditControl::INPUT_TYPE_NUMBER; + break; + + case SettingControlFormatIP: + inputType = CGUIEditControl::INPUT_TYPE_IPADDRESS; + break; + + case SettingControlFormatMD5: + inputType = CGUIEditControl::INPUT_TYPE_PASSWORD_MD5; + break; + + default: + break; + } + m_pEdit->SetInputType(inputType, heading); + + Update(); +} + +CGUIControlEditSetting::~CGUIControlEditSetting() +{ } + +bool CGUIControlEditSetting::OnClick() +{ + if (m_pEdit == NULL) + return false; + + // update our string + return m_pSetting->FromString(m_pEdit->GetLabel2()); +} + +void CGUIControlEditSetting::Update() +{ + if (m_pEdit == NULL) + return; + + CGUIControlBaseSetting::Update(); + + m_pEdit->SetLabel2(m_pSetting->ToString()); +} + +CGUIControlSeparatorSetting::CGUIControlSeparatorSetting(CGUIImage *pImage, int id) + : CGUIControlBaseSetting(id, NULL) +{ + m_pImage = pImage; + m_pImage->SetID(id); +} + +CGUIControlSeparatorSetting::~CGUIControlSeparatorSetting() +{ } diff --git a/xbmc/settings/windows/GUIControlSettings.h b/xbmc/settings/windows/GUIControlSettings.h new file mode 100644 index 0000000000000..c95195a73ec24 --- /dev/null +++ b/xbmc/settings/windows/GUIControlSettings.h @@ -0,0 +1,164 @@ +#pragma once +/* + * Copyright (C) 2005-2012 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 + * . + * + */ + +#include "utils/StdString.h" + +class CGUIControl; +class CGUIImage; +class CGUISpinControlEx; +class CGUIEditControl; +class CGUIButtonControl; +class CGUIRadioButtonControl; + +class CSetting; +class CSettingPath; + +class CGUIControlBaseSetting +{ +public: + CGUIControlBaseSetting(int id, CSetting *pSetting); + virtual ~CGUIControlBaseSetting() {} + + int GetID() { return m_id; } + CSetting* GetSetting() { return m_pSetting; } + + /*! + \brief Specifies that this setting should update after a delay + Useful for settings that have options to navigate through + and may take a while, or require additional input to update + once the final setting is chosen. Settings default to updating + instantly. + \sa IsDelayed() + */ + void SetDelayed() { m_delayed = true; } + + /*! + \brief Returns whether this setting should have delayed update + \return true if the setting's update should be delayed + \sa SetDelayed() + */ + bool IsDelayed() const { return m_delayed; } + + /*! + \brief Specifies that this setting is enabled or disabled + This is used for settings which are enabled/disabled based + on conditions involving other settings and their values. + It must not be confused with a setting spin control being + disabled because it contains less than two items. + \param enabled Whether the setting is enabled or disabled + \sa IsEnabled() + */ + void SetEnabled(bool enabled) { m_enabled = enabled; } + + /*! + \brief Returns whether this setting is enabled or disabled + This state is independent of the real enabled state of a + setting control but represents the enabled state of the + setting itself based on specific conditions. + \return true if the setting is enabled otherwise false + \sa SetEnabled() + */ + bool IsEnabled() const { return m_enabled; } + + virtual CGUIControl* GetControl() { return NULL; } + virtual bool OnClick() { return false; } + virtual void Update(); + virtual void Clear() = 0; ///< Clears the attached control +protected: + int m_id; + CSetting* m_pSetting; + bool m_delayed; + bool m_enabled; +}; + +class CGUIControlRadioButtonSetting : public CGUIControlBaseSetting +{ +public: + CGUIControlRadioButtonSetting(CGUIRadioButtonControl* pRadioButton, int id, CSetting *pSetting); + virtual ~CGUIControlRadioButtonSetting(); + + void Select(bool bSelect); + + virtual CGUIControl* GetControl() { return (CGUIControl*)m_pRadioButton; } + virtual bool OnClick(); + virtual void Update(); + virtual void Clear() { m_pRadioButton = NULL; } +private: + CGUIRadioButtonControl *m_pRadioButton; +}; + +class CGUIControlSpinExSetting : public CGUIControlBaseSetting +{ +public: + CGUIControlSpinExSetting(CGUISpinControlEx* pSpin, int id, CSetting *pSetting); + virtual ~CGUIControlSpinExSetting(); + + virtual CGUIControl* GetControl() { return (CGUIControl*)m_pSpin; } + virtual bool OnClick(); + virtual void Update(); + virtual void Clear() { m_pSpin = NULL; } +private: + CGUISpinControlEx *m_pSpin; +}; + +class CGUIControlButtonSetting : public CGUIControlBaseSetting +{ +public: + CGUIControlButtonSetting(CGUIButtonControl* pButton, int id, CSetting *pSetting); + virtual ~CGUIControlButtonSetting(); + + virtual CGUIControl* GetControl() { return (CGUIControl*)m_pButton; } + virtual bool OnClick(); + virtual void Update(); + virtual void Clear() { m_pButton = NULL; } + + static bool GetPath(CSettingPath *pathSetting); +private: + CGUIButtonControl *m_pButton; +}; + +class CGUIControlEditSetting : public CGUIControlBaseSetting +{ +public: + CGUIControlEditSetting(CGUIEditControl* pButton, int id, CSetting *pSetting); + virtual ~CGUIControlEditSetting(); + + virtual CGUIControl* GetControl() { return (CGUIControl*)m_pEdit; } + virtual bool OnClick(); + virtual void Update(); + virtual void Clear() { m_pEdit = NULL; } +private: + CGUIEditControl *m_pEdit; +}; + +class CGUIControlSeparatorSetting : public CGUIControlBaseSetting +{ +public: + CGUIControlSeparatorSetting(CGUIImage* pImage, int id); + virtual ~CGUIControlSeparatorSetting(); + + virtual CGUIControl* GetControl() { return (CGUIControl*)m_pImage; } + virtual bool OnClick() { return false; } + virtual void Update() {} + virtual void Clear() { m_pImage = NULL; } +private: + CGUIImage *m_pImage; +}; diff --git a/xbmc/settings/windows/GUISettingControls.cpp b/xbmc/settings/windows/GUISettingControls.cpp deleted file mode 100644 index 40a6df2eb4797..0000000000000 --- a/xbmc/settings/windows/GUISettingControls.cpp +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Copyright (C) 2005-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 - * . - * - */ - -#include "GUISettingControls.h" -#include "guilib/GUIRadioButtonControl.h" -#include "guilib/GUISpinControlEx.h" -#include "guilib/GUIEditControl.h" -#include "Util.h" -#include "dialogs/GUIDialogOK.h" -#include "settings/GUISettings.h" -#include "guilib/GUIImage.h" -#include "guilib/LocalizeStrings.h" -#include "addons/AddonManager.h" - -CGUIBaseSettingControl::CGUIBaseSettingControl(int id, CSetting *pSetting) -{ - m_id = id; - m_pSetting = pSetting; - m_delayed = false; -} - -CGUIRadioButtonSettingControl::CGUIRadioButtonSettingControl(CGUIRadioButtonControl *pRadioButton, int id, CSetting *pSetting) - : CGUIBaseSettingControl(id, pSetting) -{ - m_pRadioButton = pRadioButton; - m_pRadioButton->SetID(id); - Update(); -} - -CGUIRadioButtonSettingControl::~CGUIRadioButtonSettingControl() -{} - -bool CGUIRadioButtonSettingControl::OnClick() -{ - ((CSettingBool *)m_pSetting)->SetData(!((CSettingBool *)m_pSetting)->GetData()); - return true; -} - -void CGUIRadioButtonSettingControl::Update() -{ - if (m_pRadioButton) - m_pRadioButton->SetSelected(((CSettingBool *)m_pSetting)->GetData()); -} - -CGUISpinExSettingControl::CGUISpinExSettingControl(CGUISpinControlEx *pSpin, int id, CSetting *pSetting) - : CGUIBaseSettingControl(id, pSetting) -{ - m_pSpin = pSpin; - m_pSpin->SetID(id); - if (pSetting->GetControlType() == SPIN_CONTROL_FLOAT) - { - CSettingFloat *pSettingFloat = (CSettingFloat *)pSetting; - m_pSpin->SetType(SPIN_CONTROL_TYPE_FLOAT); - m_pSpin->SetFloatRange(pSettingFloat->m_fMin, pSettingFloat->m_fMax); - m_pSpin->SetFloatInterval(pSettingFloat->m_fStep); - } - else if (pSetting->GetControlType() == SPIN_CONTROL_INT_PLUS || pSetting->GetControlType() == SPIN_CONTROL_INT) - { - CSettingInt *pSettingInt = (CSettingInt *)pSetting; - m_pSpin->SetType(SPIN_CONTROL_TYPE_TEXT); - m_pSpin->Clear(); - CStdString strLabel; - int i = pSettingInt->m_iMin; - if (pSettingInt->m_iLabelMin>-1) - { - strLabel=g_localizeStrings.Get(pSettingInt->m_iLabelMin); - m_pSpin->AddLabel(strLabel, pSettingInt->m_iMin); - i += pSettingInt->m_iStep; - } - for (; i <= pSettingInt->m_iMax; i += pSettingInt->m_iStep) - { - if (pSettingInt->m_iFormat > -1) - { - CStdString strFormat = g_localizeStrings.Get(pSettingInt->m_iFormat); - strLabel.Format(strFormat, i); - } - else - strLabel.Format(pSettingInt->m_strFormat, i); - m_pSpin->AddLabel(strLabel, i); - } - } - else // if (pSetting->GetControlType() == SPIN_CONTROL_TEXT) - { - m_pSpin->SetType(SPIN_CONTROL_TYPE_TEXT); - m_pSpin->Clear(); - } - Update(); -} - -CGUISpinExSettingControl::~CGUISpinExSettingControl() -{} - -bool CGUISpinExSettingControl::OnClick() -{ - // TODO: Should really check for a change here (as end of spincontrols may - // cause no change) - if (m_pSetting->GetControlType() == SPIN_CONTROL_FLOAT) - ((CSettingFloat *)m_pSetting)->SetData(m_pSpin->GetFloatValue()); - else - { - if (m_pSetting->GetType() == SETTINGS_TYPE_INT) - { - CSettingInt *pSettingInt = (CSettingInt *)m_pSetting; - pSettingInt->SetData(m_pSpin->GetValue()); - } - } - return true; -} - -void CGUISpinExSettingControl::Update() -{ - if (!m_pSpin) - return; - if (m_pSetting->GetControlType() == SPIN_CONTROL_FLOAT) - { - CSettingFloat *pSettingFloat = (CSettingFloat *)m_pSetting; - m_pSpin->SetFloatValue(pSettingFloat->GetData()); - } - else if (m_pSetting->GetControlType() == SPIN_CONTROL_INT_PLUS || m_pSetting->GetControlType() == SPIN_CONTROL_INT) - { - CSettingInt *pSettingInt = (CSettingInt *)m_pSetting; - m_pSpin->SetValue(pSettingInt->GetData()); - } -} - -CGUIButtonSettingControl::CGUIButtonSettingControl(CGUIButtonControl *pButton, int id, CSetting *pSetting) - : CGUIBaseSettingControl(id, pSetting) -{ - m_pButton = pButton; - m_pButton->SetID(id); - Update(); -} - -CGUIButtonSettingControl::~CGUIButtonSettingControl() -{} - -bool CGUIButtonSettingControl::OnClick() -{ - // this is pretty much a no-op as all click action is done in the calling class - Update(); - return true; -} - -void CGUIButtonSettingControl::Update() -{ - CStdString strText = ((CSettingString *)m_pSetting)->GetData(); - if (m_pSetting->GetType() == SETTINGS_TYPE_ADDON) - { - ADDON::AddonPtr addon; - if (ADDON::CAddonMgr::Get().GetAddon(strText, addon)) - strText = addon->Name(); - if (strText.IsEmpty()) - strText = g_localizeStrings.Get(231); // None - } - else if (m_pSetting->GetControlType() == BUTTON_CONTROL_PATH_INPUT) - { - CStdString shortPath; - if (CUtil::MakeShortenPath(strText, shortPath, 30 )) - strText = shortPath; - } - else if (m_pSetting->GetControlType() == BUTTON_CONTROL_STANDARD) - return; - if (m_pButton) - m_pButton->SetLabel2(strText); -} - -CGUIEditSettingControl::CGUIEditSettingControl(CGUIEditControl *pEdit, int id, CSetting *pSetting) - : CGUIBaseSettingControl(id, pSetting) -{ - m_needsUpdate = false; - m_pEdit = pEdit; - m_pEdit->SetID(id); - int heading = ((CSettingString *)m_pSetting)->m_iHeadingString; - if (heading < 0) heading = 0; - if (pSetting->GetControlType() == EDIT_CONTROL_HIDDEN_INPUT) - m_pEdit->SetInputType(CGUIEditControl::INPUT_TYPE_PASSWORD, heading); - else if (pSetting->GetControlType() == EDIT_CONTROL_MD5_INPUT) - m_pEdit->SetInputType(CGUIEditControl::INPUT_TYPE_PASSWORD_MD5, heading); - else if (pSetting->GetControlType() == EDIT_CONTROL_IP_INPUT) - m_pEdit->SetInputType(CGUIEditControl::INPUT_TYPE_IPADDRESS, heading); - else if (pSetting->GetControlType() == EDIT_CONTROL_NUMBER_INPUT) - m_pEdit->SetInputType(CGUIEditControl::INPUT_TYPE_NUMBER, heading); - else if (pSetting->GetControlType() == EDIT_CONTROL_HIDDEN_NUMBER_VERIFY_NEW) - m_pEdit->SetInputType(CGUIEditControl::INPUT_TYPE_PASSWORD_NUMBER_VERIFY_NEW, heading); - else - m_pEdit->SetInputType(CGUIEditControl::INPUT_TYPE_TEXT, heading); - Update(); -} - -CGUIEditSettingControl::~CGUIEditSettingControl() -{ -} - -bool CGUIEditSettingControl::OnClick() -{ - // update our string - ((CSettingString *)m_pSetting)->SetData(m_pEdit->GetLabel2()); - // we update on exit only - m_needsUpdate = true; - return false; -} - -void CGUIEditSettingControl::Update() -{ - if (!m_needsUpdate && m_pEdit) - m_pEdit->SetLabel2(((CSettingString *)m_pSetting)->GetData()); -} - -bool CGUIEditSettingControl::IsValidIPAddress(const CStdString &strIP) -{ - const char* s = strIP.c_str(); - bool legalFormat = true; - bool numSet = false; - int num = 0; - int dots = 0; - - while (*s != '\0') - { - if (*s == '.') - { - ++dots; - - // There must be a number before a . - if (!numSet) - { - legalFormat = false; - break; - } - - if (num > 255) - { - legalFormat = false; - break; - } - - num = 0; - numSet = false; - } - else if (*s >= '0' && *s <= '9') - { - num = (num * 10) + (*s - '0'); - numSet = true; - } - else - { - legalFormat = false; - break; - } - - ++s; - } - - if (legalFormat) - { - if (!numSet) - { - legalFormat = false; - } - - if (num > 255 || dots != 3) - { - legalFormat = false; - } - } - - if (!legalFormat) - CGUIDialogOK::ShowAndGetInput(257, 724, 725, 0); - - return legalFormat; -} - -CGUISeparatorSettingControl::CGUISeparatorSettingControl(CGUIImage *pImage, int id, CSetting *pSetting) - : CGUIBaseSettingControl(id, pSetting) -{ - m_pImage = pImage; - m_pImage->SetID(id); -} - -CGUISeparatorSettingControl::~CGUISeparatorSettingControl() -{} - diff --git a/xbmc/settings/windows/GUISettingControls.h b/xbmc/settings/windows/GUISettingControls.h deleted file mode 100644 index 576cc55b80153..0000000000000 --- a/xbmc/settings/windows/GUISettingControls.h +++ /dev/null @@ -1,130 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-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 - * . - * - */ - -#include "utils/StdString.h" - -class CGUIImage; -class CGUISpinControlEx; -class CGUIEditControl; -class CGUIButtonControl; -class CGUIRadioButtonControl; - -class CSetting; - -class CGUIBaseSettingControl -{ -public: - CGUIBaseSettingControl(int id, CSetting *pSetting); - virtual ~CGUIBaseSettingControl() {} - virtual bool OnClick() { return false; }; - virtual void Update() {}; - int GetID() { return m_id; }; - CSetting* GetSetting() { return m_pSetting; }; - virtual bool NeedsUpdate() { return false; }; ///< Returns true if the control needs an update - virtual void Reset() {}; ///< Resets the NeedsUpdate() state - virtual void Clear()=0; ///< Clears the attached control - - /*! - \brief Specifies that this setting should update after a delay - Useful for settings that have options to navigate through - and may take a while, or require additional input to update - once the final setting is chosen. Settings default to updating - instantly. - \sa IsDelayed() - */ - void SetDelayed() { m_delayed = true; }; - - /*! - \brief Returns whether this setting should have delayed update - \return true if the setting's update should be delayed - \sa SetDelayed() - */ - bool IsDelayed() const { return m_delayed; }; -protected: - int m_id; - CSetting* m_pSetting; - bool m_delayed; -}; - -class CGUIRadioButtonSettingControl : public CGUIBaseSettingControl -{ -public: - CGUIRadioButtonSettingControl(CGUIRadioButtonControl* pRadioButton, int id, CSetting *pSetting); - virtual ~CGUIRadioButtonSettingControl(); - virtual bool OnClick(); - virtual void Update(); - virtual void Clear() { m_pRadioButton = NULL; } - void Select(bool bSelect); -private: - CGUIRadioButtonControl *m_pRadioButton; -}; - -class CGUISpinExSettingControl : public CGUIBaseSettingControl -{ -public: - CGUISpinExSettingControl(CGUISpinControlEx* pSpin, int id, CSetting *pSetting); - virtual ~CGUISpinExSettingControl(); - virtual bool OnClick(); - virtual void Update(); - virtual void Clear() { m_pSpin = NULL; } -private: - CGUISpinControlEx *m_pSpin; -}; - -class CGUIButtonSettingControl : public CGUIBaseSettingControl -{ -public: - CGUIButtonSettingControl(CGUIButtonControl* pButton, int id, CSetting *pSetting); - virtual ~CGUIButtonSettingControl(); - virtual bool OnClick(); - virtual void Update(); - virtual void Clear() { m_pButton = NULL; } -private: - CGUIButtonControl *m_pButton; -}; - -class CGUIEditSettingControl : public CGUIBaseSettingControl -{ -public: - CGUIEditSettingControl(CGUIEditControl* pButton, int id, CSetting *pSetting); - virtual ~CGUIEditSettingControl(); - virtual bool OnClick(); - virtual void Update(); - virtual bool NeedsUpdate() { return m_needsUpdate; }; - virtual void Reset() { m_needsUpdate = false; }; - virtual void Clear() { m_pEdit = NULL; } -private: - bool IsValidIPAddress(const CStdString &strIP); - CGUIEditControl *m_pEdit; - bool m_needsUpdate; -}; - -class CGUISeparatorSettingControl : public CGUIBaseSettingControl -{ -public: - CGUISeparatorSettingControl(CGUIImage* pImage, int id, CSetting *pSetting); - virtual ~CGUISeparatorSettingControl(); - virtual bool OnClick() { return false; }; - virtual void Update() {}; - virtual void Clear() { m_pImage = NULL; } -private: - CGUIImage *m_pImage; -}; diff --git a/xbmc/settings/windows/GUIWindowSettingsCategory.cpp b/xbmc/settings/windows/GUIWindowSettingsCategory.cpp index 6f5741660038e..32da9b2a8520a 100644 --- a/xbmc/settings/windows/GUIWindowSettingsCategory.cpp +++ b/xbmc/settings/windows/GUIWindowSettingsCategory.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2013 Team XBMC + * Copyright (C) 2005-2012 Team XBMC * http://www.xbmc.org * * This Program is free software; you can redistribute it and/or modify @@ -18,117 +18,39 @@ * */ -#include "system.h" -#include "GUIUserMessages.h" #include "GUIWindowSettingsCategory.h" -#include "Application.h" -#include "ApplicationMessenger.h" -#include "interfaces/Builtins.h" -#include "input/KeyboardLayoutConfiguration.h" -#include "filesystem/Directory.h" -#include "Util.h" -#include "guilib/GUISpinControlEx.h" -#include "guilib/GUIRadioButtonControl.h" -#include "guilib/GUIEditControl.h" -#include "guilib/GUIImage.h" -#include "utils/Weather.h" -#include "music/MusicDatabase.h" -#include "profiles/ProfilesManager.h" -#include "video/VideoDatabase.h" -#include "view/ViewDatabase.h" -#include "view/ViewState.h" -#include "PlayListPlayer.h" -#include "addons/Skin.h" -#include "guilib/GUIAudioManager.h" -#include "GUIPassword.h" -#include "GUIInfoManager.h" -#include "dialogs/GUIDialogGamepad.h" -#include "dialogs/GUIDialogNumeric.h" -#include "dialogs/GUIDialogFileBrowser.h" -#include "addons/GUIDialogAddonSettings.h" -#include "addons/GUIWindowAddonBrowser.h" -#include "dialogs/GUIDialogContextMenu.h" -#include "dialogs/GUIDialogYesNo.h" -#include "dialogs/GUIDialogOK.h" -#include "dialogs/GUIDialogProgress.h" +#include "GUIUserMessages.h" #include "dialogs/GUIDialogKaiToast.h" -#include "addons/Visualisation.h" -#include "addons/AddonManager.h" -#include "addons/AddonInstaller.h" -#include "storage/MediaManager.h" -#include "network/Network.h" +#include "dialogs/GUIDialogTextViewer.h" +#include "dialogs/GUIDialogYesNo.h" #include "guilib/GUIControlGroupList.h" -#include "guilib/GUIWindowManager.h" -#include "guilib/GUIFontManager.h" -#include "cores/AudioEngine/AEFactory.h" -#include "cores/paplayer/AudioDecoder.h" -#ifdef _LINUX -#include "LinuxTimezone.h" -#include -#ifdef HAS_HAL -#include "HALManager.h" -#endif -#endif -#if defined(TARGET_DARWIN_OSX) -#include "osx/XBMCHelper.h" -#endif -#include "network/GUIDialogAccessPoints.h" -#include "filesystem/Directory.h" - -#include "FileItem.h" +#include "guilib/GUIEditControl.h" +#include "guilib/GUIImage.h" +#include "guilib/GUIRadioButtonControl.h" +#include "guilib/GUISpinControlEx.h" #include "guilib/GUIToggleButtonControl.h" -#include "filesystem/SpecialProtocol.h" - -#include "network/Zeroconf.h" -#include "peripherals/Peripherals.h" -#include "peripherals/dialogs/GUIDialogPeripheralManager.h" -#include "peripherals/devices/PeripheralImon.h" - -#ifdef _WIN32 -#include "WIN32Util.h" -#endif -#include -#include "settings/Settings.h" -#include "settings/AdvancedSettings.h" -#include "settings/DisplaySettings.h" -#include "settings/MediaSourceSettings.h" -#include "input/MouseStat.h" -#if defined(TARGET_WINDOWS) -#include "input/windows/WINJoystick.h" -#elif defined(HAS_SDL_JOYSTICK) -#include "input/SDLJoystick.h" -#endif +#include "guilib/GUIWindowManager.h" +#include "guilib/Key.h" #include "guilib/LocalizeStrings.h" -#include "LangInfo.h" -#include "utils/CharsetConverter.h" -#include "utils/StringUtils.h" -#include "utils/URIUtils.h" -#include "utils/SystemInfo.h" -#include "windowing/WindowingFactory.h" -#include "pvr/dialogs/GUIDialogPVRChannelManager.h" -#include "pvr/PVRManager.h" -#include "pvr/addons/PVRClients.h" - -#if defined(HAVE_LIBCRYSTALHD) -#include "cores/dvdplayer/DVDCodecs/Video/CrystalHD.h" -#endif - -#if defined(HAS_AIRPLAY) -#include "network/AirPlayServer.h" -#endif - -#if defined(HAS_WEB_SERVER) -#include "network/WebServer.h" -#endif +#include "settings/DisplaySettings.h" +#include "settings/Settings.h" +#include "utils/log.h" +#include "view/ViewStateSettings.h" using namespace std; -using namespace XFILE; -using namespace ADDON; -using namespace PVR; -using namespace PERIPHERALS; -#define CONTROL_GROUP_BUTTONS 0 -#define CONTROL_GROUP_SETTINGS 1 +#define SETTINGS_PICTURES WINDOW_SETTINGS_MYPICTURES - WINDOW_SETTINGS_START +#define SETTINGS_PROGRAMS WINDOW_SETTINGS_MYPROGRAMS - WINDOW_SETTINGS_START +#define SETTINGS_WEATHER WINDOW_SETTINGS_MYWEATHER - WINDOW_SETTINGS_START +#define SETTINGS_MUSIC WINDOW_SETTINGS_MYMUSIC - WINDOW_SETTINGS_START +#define SETTINGS_SYSTEM WINDOW_SETTINGS_SYSTEM - WINDOW_SETTINGS_START +#define SETTINGS_VIDEOS WINDOW_SETTINGS_MYVIDEOS - WINDOW_SETTINGS_START +#define SETTINGS_SERVICE WINDOW_SETTINGS_SERVICE - WINDOW_SETTINGS_START +#define SETTINGS_APPEARANCE WINDOW_SETTINGS_APPEARANCE - WINDOW_SETTINGS_START +#define SETTINGS_PVR WINDOW_SETTINGS_MYPVR - WINDOW_SETTINGS_START + +#define SETTING_DELAY 1500 + #define CONTROL_SETTINGS_LABEL 2 #define CATEGORY_GROUP_ID 3 #define SETTINGS_GROUP_ID 5 @@ -140,17 +62,36 @@ using namespace PERIPHERALS; #define CONTROL_DEFAULT_EDIT 12 #define CONTROL_START_BUTTONS -100 #define CONTROL_START_CONTROL -80 +#define CONTRL_BTN_LEVELS 20 + +typedef struct { + int id; + string name; +} SettingGroup; + +static const SettingGroup s_settingGroupMap[] = { { SETTINGS_PICTURES, "pictures" }, + { SETTINGS_PROGRAMS, "programs" }, + { SETTINGS_WEATHER, "weather" }, + { SETTINGS_MUSIC, "music" }, + { SETTINGS_SYSTEM, "system" }, + { SETTINGS_VIDEOS, "videos" }, + { SETTINGS_SERVICE, "services" }, + { SETTINGS_APPEARANCE, "appearance" }, + { SETTINGS_PVR, "pvr" } }; + +#define SettingGroupSize sizeof(s_settingGroupMap) / sizeof(SettingGroup) CGUIWindowSettingsCategory::CGUIWindowSettingsCategory(void) - : CGUIWindow(WINDOW_SETTINGS_MYPICTURES, "SettingsCategory.xml") + : CGUIWindow(WINDOW_SETTINGS_MYPICTURES, "SettingsCategory.xml"), + m_settings(CSettings::Get()), + m_iCategory(0), m_iSection(0), + m_delayedTimer(this), + m_returningFromSkinLoad(false) { m_loadType = KEEP_IN_MEMORY; - m_pOriginalSpin = NULL; - m_pOriginalRadioButton = NULL; - m_pOriginalButton = NULL; - m_pOriginalCategoryButton = NULL; - m_pOriginalImage = NULL; - m_pOriginalEdit = NULL; + + newOriginalEdit = false; + // set the correct ID range... m_idRange.clear(); m_idRange.push_back(WINDOW_SETTINGS_MYPICTURES); @@ -162,145 +103,300 @@ CGUIWindowSettingsCategory::CGUIWindowSettingsCategory(void) m_idRange.push_back(WINDOW_SETTINGS_SERVICE); m_idRange.push_back(WINDOW_SETTINGS_APPEARANCE); m_idRange.push_back(WINDOW_SETTINGS_MYPVR); - - m_iScreen = 0; - m_strOldTrackFormat = ""; - m_strOldTrackFormatRight = ""; - m_returningFromSkinLoad = false; - m_delayedSetting.reset(); } CGUIWindowSettingsCategory::~CGUIWindowSettingsCategory(void) { FreeControls(); - delete m_pOriginalEdit; -} - -bool CGUIWindowSettingsCategory::OnBack(int actionID) -{ - g_settings.Save(); - m_lastControlID = 0; // don't save the control as we go to a different window each time - return CGUIWindow::OnBack(actionID); + if (newOriginalEdit) + { + delete m_pOriginalEdit; + m_pOriginalEdit = NULL; + } } bool CGUIWindowSettingsCategory::OnMessage(CGUIMessage &message) { switch (message.GetMessage()) { - case GUI_MSG_CLICKED: + case GUI_MSG_WINDOW_INIT: + { + m_delayedSetting.reset(); + m_currentSetting.reset(); + if (message.GetParam1() != WINDOW_INVALID && !m_returningFromSkinLoad) + { // coming to this window first time (ie not returning back from some other window) + // so we reset our section and control states + m_iCategory = 0; + ResetControlStates(); + } + + m_iSection = (int)message.GetParam2() - (int)CGUIWindow::GetID(); + CGUIWindow::OnMessage(message); + m_returningFromSkinLoad = false; + return true; + } + + case GUI_MSG_WINDOW_DEINIT: { - unsigned int iControl = message.GetSenderId(); - for (unsigned int i = 0; i < m_vecSettings.size(); i++) + // cancel any delayed changes + if (m_delayedSetting != NULL) { - if (m_vecSettings[i]->GetID() == (int)iControl) - OnClick(m_vecSettings[i]); + m_delayedTimer.Stop(); + CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), GetID()); + OnMessage(message); } + + CGUIWindow::OnMessage(message); + FreeControls(); + return true; } - break; - case GUI_MSG_FOCUSED: + + case GUI_MSG_FOCUSED: { CGUIWindow::OnMessage(message); - int focusedControl = GetFocusedControlID(); - if (focusedControl >= CONTROL_START_BUTTONS && focusedControl < (int)(CONTROL_START_BUTTONS + m_vecSections.size()) && - focusedControl - CONTROL_START_BUTTONS != m_iSection && !m_returningFromSkinLoad) + if (!m_returningFromSkinLoad) { - // changing section, check for updates and cancel any delayed changes - m_delayedSetting.reset(); - CheckForUpdates(); - - if (m_vecSections[focusedControl-CONTROL_START_BUTTONS]->m_strCategory == "masterlock") + // cancel any delayed changes + if (m_delayedSetting != NULL) { - if (!g_passwordManager.IsMasterLockUnlocked(true)) - { // unable to go to this category - focus the previous one - SET_CONTROL_FOCUS(CONTROL_START_BUTTONS + m_iSection, 0); - return false; - } + m_delayedTimer.Stop(); + CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), GetID(), 1); // param1 = 1 for "reset the control if it's invalid" + OnMessage(message); } - if (m_vecSections[focusedControl-CONTROL_START_BUTTONS]->m_strCategory == "pvrparental") + + int focusedControl = GetFocusedControlID(); + // check if we have changed the category and need to create new setting controls + if (focusedControl >= CONTROL_START_BUTTONS && focusedControl < (int)(CONTROL_START_BUTTONS + m_categories.size()) && + focusedControl - CONTROL_START_BUTTONS != m_iCategory) { - if (!g_PVRManager.CheckParentalPIN(g_localizeStrings.Get(19262).c_str())) - { // unable to go to this category - focus the previous one - SET_CONTROL_FOCUS(CONTROL_START_BUTTONS + m_iSection, 0); + if (!m_categories[focusedControl - CONTROL_START_BUTTONS]->CanAccess()) + { + // unable to go to this category - focus the previous one + SET_CONTROL_FOCUS(CONTROL_START_BUTTONS + m_iCategory, 0); return false; } - } - - m_iSection = focusedControl - CONTROL_START_BUTTONS; - CreateSettings(); + m_iCategory = focusedControl - CONTROL_START_BUTTONS; + CreateSettings(); + } + else if (focusedControl >= CONTROL_START_CONTROL && focusedControl < (int)(CONTROL_START_CONTROL + m_settingControls.size())) + m_currentSetting = GetSettingControl(focusedControl); } return true; } - break; - case GUI_MSG_LOAD_SKIN: + + case GUI_MSG_CLICKED: + { + BaseSettingControlPtr control = GetSettingControl(message.GetSenderId()); + if (control != NULL) + OnClick(control); + + break; + } + + case GUI_MSG_LOAD_SKIN: { if (IsActive()) m_returningFromSkinLoad = true; + break; } - break; - case GUI_MSG_WINDOW_INIT: + + case GUI_MSG_UPDATE_ITEM: { - m_delayedSetting.reset(); - if (message.GetParam1() != WINDOW_INVALID && !m_returningFromSkinLoad) - { // coming to this window first time (ie not returning back from some other window) - // so we reset our section and control states - m_iSection = 0; - ResetControlStates(); + if (m_delayedSetting != NULL) + { + // if updating the setting fails and param1 has been specifically set + // we need to call OnSettingChanged() to restore a valid value in the + // setting control + if (!m_delayedSetting->OnClick() && message.GetParam1() != 0) + OnSettingChanged(m_delayedSetting->GetSetting()); + m_delayedSetting.reset(); + return true; } - m_iScreen = (int)message.GetParam2() - (int)CGUIWindow::GetID(); - CGUIWindow::OnMessage(message); - m_returningFromSkinLoad = false; - return true; - } - break; - case GUI_MSG_UPDATE_ITEM: - if (m_delayedSetting) - { - OnSettingChanged(m_delayedSetting); - m_delayedSetting.reset(); - return true; + break; } - break; - case GUI_MSG_UPDATE: - if (HasID(message.GetSenderId())) + + case GUI_MSG_UPDATE: { - int focusedControl = GetFocusedControlID(); - CreateSettings(); - SET_CONTROL_FOCUS(focusedControl, 0); + if (IsActive() && HasID(message.GetSenderId())) + { + int focusedControl = GetFocusedControlID(); + CreateSettings(); + SET_CONTROL_FOCUS(focusedControl, 0); + } + break; } - break; - case GUI_MSG_NOTIFY_ALL: + + case GUI_MSG_NOTIFY_ALL: { if (message.GetParam1() == GUI_MSG_WINDOW_RESIZE) { - // Cancel delayed setting - it's only used for res changing anyway - m_delayedSetting.reset(); - if (IsActive() && CDisplaySettings::Get().GetDisplayResolution() != g_graphicsContext.GetVideoResolution()) + if (IsActive() && CDisplaySettings::Get().GetCurrentResolution() != g_graphicsContext.GetVideoResolution()) { CDisplaySettings::Get().SetCurrentResolution(g_graphicsContext.GetVideoResolution(), true); CreateSettings(); } } + break; } - break; - case GUI_MSG_WINDOW_DEINIT: + } + + return CGUIWindow::OnMessage(message); +} + +bool CGUIWindowSettingsCategory::OnAction(const CAction &action) +{ + switch (action.GetID()) + { + case ACTION_SETTINGS_RESET: { - m_delayedSetting.reset(); + if (CGUIDialogYesNo::ShowAndGetInput(10041, 0, 10042, 0)) + { + for(vector::iterator it = m_settingControls.begin(); it != m_settingControls.end(); it++) + { + CSetting *setting = (*it)->GetSetting(); + if (setting != NULL) + setting->Reset(); + } + } + return true; + } - CheckForUpdates(); - CGUIWindow::OnMessage(message); - FreeControls(); + case ACTION_SETTINGS_LEVEL_CHANGE: + { + CViewStateSettings::Get().CycleSettingLevel(); + CSettings::Get().Save(); + + // try to keep the current position + std::string oldCategory; + if (m_iCategory >= 0 && m_iCategory < (int)m_categories.size()) + oldCategory = m_categories[m_iCategory]->GetId(); + + SET_CONTROL_LABEL(CONTRL_BTN_LEVELS, 10036 + (int)CViewStateSettings::Get().GetSettingLevel()); + // only re-create the categories, the settings will be created later + SetupControls(false); + + m_iCategory = 0; + // try to find the category that was previously selected + if (!oldCategory.empty()) + { + for (int i = 0; i < (int)m_categories.size(); i++) + { + if (m_categories[i]->GetId() == oldCategory) + { + m_iCategory = i; + break; + } + } + } + + CreateSettings(); + return true; + } + + case ACTION_SHOW_INFO: + { + int label = -1; + int help = -1; + int focusedControl = GetFocusedControlID(); + // check if we are focusing a category + if (focusedControl >= CONTROL_START_BUTTONS && focusedControl < (int)(CONTROL_START_BUTTONS + m_categories.size())) + { + CSettingCategory *category = m_categories[focusedControl - CONTROL_START_BUTTONS]; + label = category->GetLabel(); + help = category->GetHelp(); + } + else if (focusedControl >= CONTROL_START_CONTROL && focusedControl < (int)(CONTROL_START_CONTROL + m_settingControls.size())) + { + CSetting *setting = GetSettingControl(focusedControl)->GetSetting(); + if (setting != NULL) + { + label = setting->GetLabel(); + help = setting->GetHelp(); + } + } + else + break; + + if (help >= 0) + { + CGUIDialogTextViewer *dialog = (CGUIDialogTextViewer*)g_windowManager.GetWindow(WINDOW_DIALOG_TEXT_VIEWER); + if (dialog != NULL) + { + if (label < 0) + label = 10043; // "Help" + dialog->SetHeading(g_localizeStrings.Get(label)); + dialog->SetText(g_localizeStrings.Get(help)); + dialog->DoModal(); + } + } + else + CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(10043), g_localizeStrings.Get(10044), 2000U); return true; } - break; + + default: + break; } - return CGUIWindow::OnMessage(message); + + return CGUIWindow::OnAction(action); +} + +bool CGUIWindowSettingsCategory::OnBack(int actionID) +{ + m_settings.Save(); + m_lastControlID = 0; // don't save the control as we go to a different window each time + + return CGUIWindow::OnBack(actionID); +} + +void CGUIWindowSettingsCategory::DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions) +{ + // update alpha status of current button + bool bAlphaFaded = false; + CGUIControl *control = GetFirstFocusableControl(CONTROL_START_BUTTONS + m_iCategory); + if (control && !control->HasFocus()) + { + if (control->GetControlType() == CGUIControl::GUICONTROL_BUTTON) + { + control->SetFocus(true); + ((CGUIButtonControl *)control)->SetAlpha(0x80); + bAlphaFaded = true; + } + else if (control->GetControlType() == CGUIControl::GUICONTROL_TOGGLEBUTTON) + { + control->SetFocus(true); + ((CGUIButtonControl *)control)->SetSelected(true); + bAlphaFaded = true; + } + } + CGUIWindow::DoProcess(currentTime, dirtyregions); + if (bAlphaFaded) + { + control->SetFocus(false); + if (control->GetControlType() == CGUIControl::GUICONTROL_BUTTON) + ((CGUIButtonControl *)control)->SetAlpha(0xFF); + else + ((CGUIButtonControl *)control)->SetSelected(false); + } +} + +void CGUIWindowSettingsCategory::OnInitWindow() +{ + SetupControls(); + CGUIWindow::OnInitWindow(); +} + +void CGUIWindowSettingsCategory::OnWindowLoaded() +{ + SET_CONTROL_LABEL(CONTRL_BTN_LEVELS, 10036 + (int)CViewStateSettings::Get().GetSettingLevel()); } -void CGUIWindowSettingsCategory::SetupControls() +void CGUIWindowSettingsCategory::SetupControls(bool createSettings /* = true */) { // cleanup first, if necessary FreeControls(); + m_pOriginalSpin = (CGUISpinControlEx*)GetControl(CONTROL_DEFAULT_SPIN); m_pOriginalRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_DEFAULT_RADIOBUTTON); m_pOriginalCategoryButton = (CGUIButtonControl *)GetControl(CONTROL_DEFAULT_CATEGORY_BUTTON); @@ -313,2650 +409,459 @@ void CGUIWindowSettingsCategory::SetupControls() { delete m_pOriginalEdit; m_pOriginalEdit = new CGUIEditControl(*m_pOriginalButton); + newOriginalEdit = true; } + m_pOriginalSpin->SetVisible(false); m_pOriginalRadioButton->SetVisible(false); m_pOriginalButton->SetVisible(false); m_pOriginalCategoryButton->SetVisible(false); m_pOriginalEdit->SetVisible(false); if (m_pOriginalImage) m_pOriginalImage->SetVisible(false); + // setup our control groups... CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(CATEGORY_GROUP_ID); if (!group) return; - // get a list of different sections - CSettingsGroup *pSettingsGroup = g_guiSettings.GetGroup(m_iScreen); - if (!pSettingsGroup) return ; + + CSettingSection *section = GetSection(m_iSection); + if (section == NULL) + return; + // update the screen string - SET_CONTROL_LABEL(CONTROL_SETTINGS_LABEL, pSettingsGroup->GetLabelID()); + SET_CONTROL_LABEL(CONTROL_SETTINGS_LABEL, section->GetLabel()); + // get the categories we need - pSettingsGroup->GetCategories(m_vecSections); - // run through and create our buttons... - int j=0; - for (unsigned int i = 0; i < m_vecSections.size(); i++) + m_categories = section->GetCategories(CViewStateSettings::Get().GetSettingLevel()); + + // go through the categories and create the necessary buttons + int buttonIdOffset = 0; + for (SettingCategoryList::const_iterator category = m_categories.begin(); category != m_categories.end(); category++) { - if (m_vecSections[i]->m_labelID == 12360 && !CProfilesManager::Get().IsMasterProfile()) - continue; CGUIButtonControl *pButton = NULL; if (m_pOriginalCategoryButton->GetControlType() == CGUIControl::GUICONTROL_TOGGLEBUTTON) pButton = new CGUIToggleButtonControl(*(CGUIToggleButtonControl *)m_pOriginalCategoryButton); else pButton = new CGUIButtonControl(*m_pOriginalCategoryButton); - pButton->SetLabel(g_localizeStrings.Get(m_vecSections[i]->m_labelID)); - pButton->SetID(CONTROL_START_BUTTONS + j); + pButton->SetLabel(g_localizeStrings.Get((*category)->GetLabel())); + pButton->SetID(CONTROL_START_BUTTONS + buttonIdOffset); pButton->SetVisible(true); pButton->AllocResources(); + group->AddControl(pButton); - j++; + buttonIdOffset++; } - if (m_iSection < 0 || m_iSection >= (int)m_vecSections.size()) - m_iSection = 0; - CreateSettings(); + + if (createSettings) + CreateSettings(); + // set focus correctly m_defaultControl = CONTROL_START_BUTTONS; } -CGUIControl* CGUIWindowSettingsCategory::AddIntBasedSpinControl(CSetting *pSetting, float groupWidth, int &iControlID) +void CGUIWindowSettingsCategory::FreeControls() { - CSettingInt *pSettingInt = (CSettingInt*)pSetting; - CGUISpinControlEx *pControl = (CGUISpinControlEx *)AddSetting(pSetting, groupWidth, iControlID); - if (!pSettingInt->m_entries.empty()) + // clear the category group + CGUIControlGroupList *control = (CGUIControlGroupList *)GetControl(CATEGORY_GROUP_ID); + if (control) { - for (map::iterator it=pSettingInt->m_entries.begin(); it != pSettingInt->m_entries.end();++it) - pControl->AddLabel(g_localizeStrings.Get(it->first), it->second); - pControl->SetValue(pSettingInt->GetData()); + control->FreeResources(); + control->ClearAll(); } - return pControl; + m_categories.clear(); + FreeSettingsControls(); } -void CGUIWindowSettingsCategory::CreateSettings() +void CGUIWindowSettingsCategory::FreeSettingsControls() { - FreeSettingsControls(); + m_currentSetting.reset(); - CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(SETTINGS_GROUP_ID); - if (!group) + // clear the settings group + CGUIControlGroupList *control = (CGUIControlGroupList *)GetControl(SETTINGS_GROUP_ID); + if (control) + { + control->FreeResources(); + control->ClearAll(); + } + + for (std::vector::iterator control = m_settingControls.begin(); control != m_settingControls.end(); control++) + (*control)->Clear(); + + m_settingControls.clear(); + m_settings.UnregisterCallback(this); +} + +void CGUIWindowSettingsCategory::OnTimeout() +{ + if (m_delayedSetting == NULL) return; - vecSettings settings; - g_guiSettings.GetSettingsGroup(m_vecSections[m_iSection], settings); - int iControlID = CONTROL_START_CONTROL; - for (unsigned int i = 0; i < settings.size(); i++) + + // we send a thread message so that it's processed the following frame (some settings won't + // like being changed during Render()) + CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), GetID(), 1); // param1 = 1 for "reset the control if it's invalid" + g_windowManager.SendThreadMessage(message, GetID()); +} + +void CGUIWindowSettingsCategory::OnSettingChanged(const CSetting *setting) +{ + if (setting == NULL || setting->GetType() == SettingTypeNone || + setting->GetType() == SettingTypeAction) + return; + + BaseSettingControlPtr pControl = GetSettingControl(setting->GetId()); + if (pControl == NULL) + return; + + const SettingDependencyMap& deps = m_settings.GetDependencies(setting->GetId()); + for (SettingDependencyMap::const_iterator depsIt = deps.begin(); depsIt != deps.end(); depsIt++) + { + for (SettingDependencies::const_iterator depIt = depsIt->second.begin(); depIt != depsIt->second.end(); depIt++) + UpdateControl(depsIt->first, *depIt); + } + + // update GUI of the changed setting as the change could have been triggered by something else + pControl->Update(); +} + +void CGUIWindowSettingsCategory::UpdateControl(const std::string &dependingSetting, const CSettingDependency &dependency) +{ + if (dependingSetting.empty()) + return; + + BaseSettingControlPtr pControl = GetSettingControl(dependingSetting); + if (pControl == NULL) + return; + + CSetting *pSetting = pControl->GetSetting(); + if (pSetting == NULL) + return; + + CheckDependency(pControl, dependency); + + const SettingDependencyMap& deps = m_settings.GetDependencies(pSetting->GetId()); + for (SettingDependencyMap::const_iterator depsIt = deps.begin(); depsIt != deps.end(); depsIt++) + { + for (SettingDependencies::const_iterator depIt = depsIt->second.begin(); depIt != depsIt->second.end(); depIt++) + UpdateControl(depsIt->first, *depIt); + } + + // update GUI of the changed setting as the change could have been triggered by something else + pControl->Update(); +} + +void CGUIWindowSettingsCategory::CheckDependency(BaseSettingControlPtr pSettingControl, const CSettingDependency &dependency) +{ + if (pSettingControl == NULL || pSettingControl->GetControl() == NULL) + return; + + CSetting *pSetting = pSettingControl->GetSetting(); + if (pSetting == NULL) + return; + + switch (dependency.GetType()) { - CSetting *pSetting = settings[i]; - CStdString strSetting = pSetting->GetSetting(); - if (pSetting->GetType() == SETTINGS_TYPE_INT) + case SettingDependencyTypeEnable: + pSettingControl->SetEnabled(dependency.Check()); + break; + + case SettingDependencyTypeUpdate: { - CGUISpinControlEx *pControl = (CGUISpinControlEx *)AddIntBasedSpinControl(pSetting, group->GetWidth(), iControlID); - CSettingInt *pSettingInt = (CSettingInt*)pSetting; - if (strSetting.Equals("videoplayer.pauseafterrefreshchange")) - { - pControl->AddLabel(g_localizeStrings.Get(13551), 0); + FillControl(pSetting, pSettingControl->GetControl()); + break; + } - for (int i = 1; i <= MAXREFRESHCHANGEDELAY; i++) - { - CStdString delayText; - delayText.Format(g_localizeStrings.Get(13553).c_str(), (double)i / 10.0); - pControl->AddLabel(delayText, i); - } - pControl->SetValue(pSettingInt->GetData()); - } - else if (strSetting.Equals("subtitles.color")) - { - for (int i = SUBTITLE_COLOR_START; i <= SUBTITLE_COLOR_END; i++) - pControl->AddLabel(g_localizeStrings.Get(760 + i), i); - pControl->SetValue(pSettingInt->GetData()); - } - else if (strSetting.Equals("lookandfeel.startupwindow")) - FillInStartupWindow(pSetting); - else if (strSetting.Equals("subtitles.height") || strSetting.Equals("karaoke.fontheight") ) - FillInSubtitleHeights(pSetting, pControl); - else if (strSetting.Equals("videoscreen.screen")) - FillInScreens(strSetting, CDisplaySettings::Get().GetDisplayResolution()); - else if (strSetting.Equals("videoscreen.resolution")) - FillInResolutions(strSetting, g_guiSettings.GetInt("videoscreen.screen"), CDisplaySettings::Get().GetDisplayResolution(), false); - else if (strSetting.Equals("epg.defaultguideview")) - FillInEpgGuideView(pSetting); - else if (strSetting.Equals("pvrplayback.startlast")) - FillInPvrStartLastChannel(pSetting); - continue; - } -#ifdef HAS_WEB_SERVER - else if (strSetting.Equals("services.webserverport")) - { - AddSetting(pSetting, group->GetWidth(), iControlID); - BaseSettingControlPtr control = GetSetting(pSetting->GetSetting()); - control->SetDelayed(); - continue; - } -#endif - else if (strSetting.Equals("services.esport")) - { -#ifdef HAS_EVENT_SERVER - AddSetting(pSetting, group->GetWidth(), iControlID); - BaseSettingControlPtr control = GetSetting(pSetting->GetSetting()); - control->SetDelayed(); - continue; -#endif - } - else if (strSetting.Equals("network.httpproxyport")) - { - AddSetting(pSetting, group->GetWidth(), iControlID); - BaseSettingControlPtr control = GetSetting(pSetting->GetSetting()); - control->SetDelayed(); - continue; - } - else if (strSetting.Equals("subtitles.font") || strSetting.Equals("karaoke.font") ) - { - AddSetting(pSetting, group->GetWidth(), iControlID); - FillInSubtitleFonts(pSetting); - continue; - } - else if (strSetting.Equals("subtitles.charset") || strSetting.Equals("locale.charset") || strSetting.Equals("karaoke.charset")) - { - AddSetting(pSetting, group->GetWidth(), iControlID); - FillInCharSets(pSetting); - continue; - } - else if (strSetting.Equals("lookandfeel.font")) - { - AddSetting(pSetting, group->GetWidth(), iControlID); - FillInSkinFonts(pSetting); - continue; - } - else if (strSetting.Equals("lookandfeel.soundskin")) - { - AddSetting(pSetting, group->GetWidth(), iControlID); - FillInSoundSkins(pSetting); - continue; - } - else if (strSetting.Equals("locale.language")) - { - AddSetting(pSetting, group->GetWidth(), iControlID); - GetSetting(pSetting->GetSetting())->SetDelayed(); - FillInLanguages(pSetting); - continue; - } - else if (strSetting.Equals("locale.audiolanguage") || strSetting.Equals("locale.subtitlelanguage")) - { - AddSetting(pSetting, group->GetWidth(), iControlID); - vector languages; - languages.push_back(g_localizeStrings.Get(308)); - languages.push_back(g_localizeStrings.Get(309)); - vector languageKeys; - languageKeys.push_back("original"); - languageKeys.push_back("default"); - FillInLanguages(pSetting, languages, languageKeys); - continue; - } -#ifdef _LINUX - else if (strSetting.Equals("locale.timezonecountry")) - { - CStdString myTimezoneCountry = g_guiSettings.GetString("locale.timezonecountry"); - int myTimezeoneCountryIndex = 0; - - CGUISpinControlEx *pControl = (CGUISpinControlEx *)AddSetting(pSetting, group->GetWidth(), iControlID); - vector countries = g_timezone.GetCounties(); - for (unsigned int i=0; i < countries.size(); i++) - { - if (countries[i] == myTimezoneCountry) - myTimezeoneCountryIndex = i; - pControl->AddLabel(countries[i], i); - } - pControl->SetValue(myTimezeoneCountryIndex); - continue; - } - else if (strSetting.Equals("locale.timezone")) - { - CStdString myTimezoneCountry = g_guiSettings.GetString("locale.timezonecountry"); - CStdString myTimezone = g_guiSettings.GetString("locale.timezone"); - int myTimezoneIndex = 0; - - CGUISpinControlEx *pControl = (CGUISpinControlEx *)AddSetting(pSetting, group->GetWidth(), iControlID); - pControl->Clear(); - vector timezones = g_timezone.GetTimezonesByCountry(myTimezoneCountry); - for (unsigned int i=0; i < timezones.size(); i++) - { - if (timezones[i] == myTimezone) - myTimezoneIndex = i; - pControl->AddLabel(timezones[i], i); - } - pControl->SetValue(myTimezoneIndex); - continue; - } -#endif - else if (strSetting.Equals("videoscreen.screenmode")) - { - AddSetting(pSetting, group->GetWidth(), iControlID); - FillInRefreshRates(strSetting, CDisplaySettings::Get().GetDisplayResolution(), false); - continue; - } - else if (strSetting.Equals("lookandfeel.skintheme")) - { - AddSetting(pSetting, group->GetWidth(), iControlID); - FillInSkinThemes(pSetting); - continue; - } - else if (strSetting.Equals("lookandfeel.skincolors")) - { - AddSetting(pSetting, group->GetWidth(), iControlID); - FillInSkinColors(pSetting); - continue; - } - /* - FIXME: setting is hidden in GUI because not supported properly. - else if (strSetting.Equals("videoplayer.displayresolution") || strSetting.Equals("pictures.displayresolution")) - { - FillInResolutions(pSetting); - } - */ - else if (strSetting.Equals("locale.country")) - { - AddSetting(pSetting, group->GetWidth(), iControlID); - FillInRegions(pSetting); - continue; - } - else if (strSetting.Equals("network.interface")) - { - FillInNetworkInterfaces(pSetting, group->GetWidth(), iControlID); - continue; - } - else if (strSetting.Equals("audiooutput.audiodevice")) - { - AddSetting(pSetting, group->GetWidth(), iControlID); - FillInAudioDevices(pSetting); - continue; - } - else if (strSetting.Equals("audiooutput.passthroughdevice")) - { - AddSetting(pSetting, group->GetWidth(), iControlID); - FillInAudioDevices(pSetting,true); - continue; - } - AddSetting(pSetting, group->GetWidth(), iControlID); - } - - if (m_vecSections[m_iSection]->m_strCategory == "network") - NetworkInterfaceChanged(); - - // update our settings (turns controls on/off as appropriate) - UpdateSettings(); -} - -void CGUIWindowSettingsCategory::UpdateSettings() -{ - for (unsigned int i = 0; i < m_vecSettings.size(); i++) - { - BaseSettingControlPtr pSettingControl = m_vecSettings[i]; - pSettingControl->Update(); - CStdString strSetting = pSettingControl->GetSetting()->GetSetting(); -#ifdef HAVE_LIBVDPAU - if (strSetting.Equals("videoplayer.vdpauUpscalingLevel")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) - { - pControl->SetEnabled(true); - } - } - else -#endif - if (strSetting.Equals("videoscreen.resolution")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) - pControl->SetEnabled(g_guiSettings.GetInt("videoscreen.screen") != DM_WINDOWED); - } - else if (strSetting.Equals("videoscreen.screenmode")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) - pControl->SetEnabled(g_guiSettings.GetInt("videoscreen.screen") != DM_WINDOWED); - } - else if (strSetting.Equals("videoscreen.fakefullscreen")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) - pControl->SetEnabled(g_guiSettings.GetInt("videoscreen.screen") != DM_WINDOWED); - } -#if defined(TARGET_DARWIN_OSX) || defined(_WIN32) - else if (strSetting.Equals("videoscreen.blankdisplays")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) - { - if (g_Windowing.IsFullScreen()) - pControl->SetEnabled(true); - else - pControl->SetEnabled(false); - } - } -#endif -#if defined(TARGET_DARWIN_OSX) - else if (strSetting.Equals("input.appleremotemode")) - { - int remoteMode = g_guiSettings.GetInt("input.appleremotemode"); - - // if it's not disabled, start the event server or else apple remote won't work - if ( remoteMode != APPLE_REMOTE_DISABLED ) - { - g_guiSettings.SetBool("services.esenabled", true); - if (!g_application.StartEventServer()) - CGUIDialogKaiToast::QueueNotification("DefaultIconWarning.png", g_localizeStrings.Get(33102), g_localizeStrings.Get(33100)); - } - - // if XBMC helper is running, prompt user before effecting change - if ( XBMCHelper::GetInstance().IsRunning() && XBMCHelper::GetInstance().GetMode()!=remoteMode ) - { - bool cancelled; - if (!CGUIDialogYesNo::ShowAndGetInput(13144, 13145, 13146, 13147, -1, -1, cancelled, 10000)) - { - // user declined, restore previous spinner state and appleremote mode - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID()); - g_guiSettings.SetInt("input.appleremotemode", XBMCHelper::GetInstance().GetMode()); - pControl->SetValue(XBMCHelper::GetInstance().GetMode()); - } - else - { - // reload configuration - XBMCHelper::GetInstance().Configure(); - } - } - else - { - // set new configuration. - XBMCHelper::GetInstance().Configure(); - } - - if (XBMCHelper::GetInstance().ErrorStarting() == true) - { - // inform user about error - CGUIDialogOK::ShowAndGetInput(13620, 13621, 20022, 20022); - - // reset spinner to disabled state - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID()); - pControl->SetValue(APPLE_REMOTE_DISABLED); - } - } - else if (strSetting.Equals("input.appleremotealwayson")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) - { - int value = g_guiSettings.GetInt("input.appleremotemode"); - if (value != APPLE_REMOTE_DISABLED) - pControl->SetEnabled(true); - else - pControl->SetEnabled(false); - } - } - else if (strSetting.Equals("input.appleremotesequencetime")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) - { - int value = g_guiSettings.GetInt("input.appleremotemode"); - if (value == APPLE_REMOTE_UNIVERSAL) - pControl->SetEnabled(true); - else - pControl->SetEnabled(false); - } - } -#endif - else if (strSetting.Equals("filelists.allowfiledeletion")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) pControl->SetEnabled(!CProfilesManager::Get().GetCurrentProfile().filesLocked() || g_passwordManager.bMasterUser); - } - else if (strSetting.Equals("filelists.showaddsourcebuttons")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) pControl->SetEnabled(CProfilesManager::Get().GetCurrentProfile().canWriteSources() || g_passwordManager.bMasterUser); - } - else if (strSetting.Equals("masterlock.startuplock")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) pControl->SetEnabled(CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE); - } - else if (strSetting.Equals("pvrmanager.channelscan")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("pvrmanager.enabled") && g_PVRClients && g_PVRClients->GetClientsSupportingChannelScan().size() > 0); - } - else if (strSetting.Equals("pvrmanager.channelmanager") || strSetting.Equals("pvrmenu.searchicons")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("pvrmanager.enabled")); - } - else if (!strSetting.Equals("pvrparental.enabled") && - (strSetting.Equals("pvrparental.pin") || strSetting.Equals("pvrparental.duration"))) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("pvrparental.enabled")); - } - else if (!strSetting.Equals("services.esenabled") - && strSetting.Left(11).Equals("services.es")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("services.esenabled")); - } - else if (strSetting.Equals("services.upnpannounce")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - pControl->SetEnabled(g_guiSettings.GetBool("services.upnpserver")); - } - else if (strSetting.Equals("audiocds.quality")) - { // only visible if we are doing non-WAV ripping - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) pControl->SetEnabled(g_guiSettings.GetInt("audiocds.encoder") != CDDARIP_ENCODER_WAV && - g_guiSettings.GetInt("audiocds.encoder") != CDDARIP_ENCODER_FLAC); - } - else if (strSetting.Equals("audiocds.bitrate")) - { // only visible if we are ripping to CBR - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) pControl->SetEnabled(g_guiSettings.GetInt("audiocds.encoder") != CDDARIP_ENCODER_WAV && - g_guiSettings.GetInt("audiocds.encoder") != CDDARIP_ENCODER_FLAC && - g_guiSettings.GetInt("audiocds.quality") == CDDARIP_QUALITY_CBR); - } - else if (strSetting.Equals("audiocds.compressionlevel")) - { // only visible if we are doing FLAC ripping - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) pControl->SetEnabled(g_guiSettings.GetInt("audiocds.encoder") == CDDARIP_ENCODER_FLAC); - } - else if ( - strSetting.Equals("audiooutput.passthroughdevice") || - strSetting.Equals("audiooutput.ac3passthrough") || - strSetting.Equals("audiooutput.dtspassthrough") || - strSetting.Equals("audiooutput.passthroughaac")) - { // only visible if we are in digital mode - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) pControl->SetEnabled(AUDIO_IS_BITSTREAM(g_guiSettings.GetInt("audiooutput.mode"))); - } - else if ( - strSetting.Equals("audiooutput.multichannellpcm" ) || - strSetting.Equals("audiooutput.truehdpassthrough") || - strSetting.Equals("audiooutput.dtshdpassthrough" )) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) - { - if (strSetting.Equals("audiooutput.dtshdpassthrough") && !g_guiSettings.GetBool("audiooutput.dtspassthrough")) - pControl->SetEnabled(false); - else - pControl->SetEnabled(g_guiSettings.GetInt("audiooutput.mode") == AUDIO_HDMI); - } - } - else if (strSetting.Equals("musicplayer.crossfadealbumtracks")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) pControl->SetEnabled(g_guiSettings.GetInt("musicplayer.crossfade") > 0); - } -#ifdef HAS_WEB_SERVER - else if (strSetting.Equals("services.webserverusername") || - strSetting.Equals("services.webserverpassword")) - { - CGUIEditControl *pControl = (CGUIEditControl *)GetControl(pSettingControl->GetID()); - if (pControl) - pControl->SetEnabled(g_guiSettings.GetBool("services.webserver")); - } -#endif -#ifdef HAS_AIRPLAY - else if ( strSetting.Equals("services.airplaypassword") || - strSetting.Equals("services.useairplaypassword")) - { - if (strSetting.Equals("services.airplaypassword")) - { - CGUIEditControl *pControl = (CGUIEditControl *)GetControl(pSettingControl->GetID()); - if (pControl) - pControl->SetEnabled(g_guiSettings.GetBool("services.useairplaypassword")); - } - else//useairplaypassword - { - CGUIRadioButtonControl *pControl = (CGUIRadioButtonControl *)GetControl(pSettingControl->GetID()); - if (pControl) - pControl->SetEnabled(g_guiSettings.GetBool("services.airplay")); - } - - //set credentials to airplay server - if (g_guiSettings.GetBool("services.airplay")) - { - CStdString password = g_guiSettings.GetString("services.airplaypassword"); - CAirPlayServer::SetCredentials(g_guiSettings.GetBool("services.useairplaypassword"), - password); - } - } -#endif//HAS_AIRPLAY - else if (strSetting.Equals("network.ipaddress") || strSetting.Equals("network.subnet") || strSetting.Equals("network.gateway") || strSetting.Equals("network.dns")) - { -#ifdef _LINUX - bool enabled = (geteuid() == 0); -#else - bool enabled = false; -#endif - CGUISpinControlEx* pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.assignment")->GetID()); - if (pControl1) - enabled = (pControl1->GetValue() == NETWORK_STATIC); - - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) pControl->SetEnabled(enabled); - } - else if (strSetting.Equals("network.assignment")) - { - CGUISpinControlEx* pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.assignment")->GetID()); -#ifdef HAS_LINUX_NETWORK - if (pControl1) - pControl1->SetEnabled(geteuid() == 0); -#endif - } - else if (strSetting.Equals("network.essid") || strSetting.Equals("network.enc") || strSetting.Equals("network.key")) - { - // Get network information - CGUISpinControlEx *ifaceControl = (CGUISpinControlEx *)GetControl(GetSetting("network.interface")->GetID()); - CStdString ifaceName = ifaceControl->GetLabel(); - CNetworkInterface* iface = g_application.getNetwork().GetInterfaceByName(ifaceName); - bool bIsWireless = iface->IsWireless(); - -#ifdef HAS_LINUX_NETWORK - bool enabled = bIsWireless && (geteuid() == 0); -#else - bool enabled = bIsWireless; -#endif - CGUISpinControlEx* pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.assignment")->GetID()); - if (pControl1) - enabled &= (pControl1->GetValue() != NETWORK_DISABLED); - - if (strSetting.Equals("network.key")) - { - pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.enc")->GetID()); - if (pControl1) enabled &= (pControl1->GetValue() != ENC_NONE); - } - - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) pControl->SetEnabled(enabled); - } - else if (strSetting.Equals("network.httpproxyserver") || strSetting.Equals("network.httpproxyport") || - strSetting.Equals("network.httpproxyusername") || strSetting.Equals("network.httpproxypassword") || - strSetting.Equals("network.httpproxytype")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("network.usehttpproxy")); - } -#ifdef HAS_LINUX_NETWORK - else if (strSetting.Equals("network.key")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - CGUISpinControlEx* pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.enc")->GetID()); - if (pControl && pControl1) - pControl->SetEnabled(!pControl1->IsDisabled() && pControl1->GetValue() > 0); - } - else if (strSetting.Equals("network.save")) - { - CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(pSettingControl->GetID()); - pControl->SetEnabled(geteuid() == 0); - } -#endif - else if (strSetting.Equals("subtitles.color") || strSetting.Equals("subtitles.style") || strSetting.Equals("subtitles.charset")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(GetSetting(strSetting)->GetID()); - pControl->SetEnabled(CUtil::IsUsingTTFSubtitles()); - } - else if (strSetting.Equals("locale.charset")) - { // TODO: Determine whether we are using a TTF font or not. - // CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - // if (pControl) pControl->SetEnabled(g_guiSettings.GetString("lookandfeel.font").Right(4) == ".ttf"); - } - else if (strSetting.Equals("screensaver.settings")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - AddonPtr addon; - if (CAddonMgr::Get().GetAddon(g_guiSettings.GetString("screensaver.mode"), addon, ADDON_SCREENSAVER)) - pControl->SetEnabled(addon->HasSettings()); - else - pControl->SetEnabled(false); - } - else if (strSetting.Equals("screensaver.preview") || - strSetting.Equals("screensaver.time") || - strSetting.Equals("screensaver.usedimonpause") || - strSetting.Equals("screensaver.usemusicvisinstead")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(GetSetting(strSetting)->GetID()); - pControl->SetEnabled(!g_guiSettings.GetString("screensaver.mode").IsEmpty()); - if (strSetting.Equals("screensaver.usedimonpause") && g_guiSettings.GetString("screensaver.mode").Equals("screensaver.xbmc.builtin.dim")) - pControl->SetEnabled(false); - } - else if (strSetting.Equals("musicfiles.trackformat")) - { - if (m_strOldTrackFormat != g_guiSettings.GetString("musicfiles.trackformat")) - { - CUtil::DeleteMusicDatabaseDirectoryCache(); - m_strOldTrackFormat = g_guiSettings.GetString("musicfiles.trackformat"); - } - } - else if (strSetting.Equals("musicfiles.trackformatright")) - { - if (m_strOldTrackFormatRight != g_guiSettings.GetString("musicfiles.trackformatright")) - { - CUtil::DeleteMusicDatabaseDirectoryCache(); - m_strOldTrackFormatRight = g_guiSettings.GetString("musicfiles.trackformatright"); - } - } - else if (strSetting.Equals("audiocds.recordingpath") || strSetting.Equals("debug.screenshotpath")) - { - CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(pSettingControl->GetID()); - if (pControl && g_guiSettings.GetString(strSetting, false).IsEmpty()) - pControl->SetLabel2(""); - } - else if (strSetting.Equals("lookandfeel.rssedit")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - pControl->SetEnabled(g_guiSettings.GetBool("lookandfeel.enablerssfeeds")); - } - else if (strSetting.Equals("lookandfeel.skinsettings")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - pControl->SetEnabled(g_SkinInfo->HasSkinFile("SkinSettings.xml")); - } - else if (strSetting.Equals("videoplayer.pauseafterrefreshchange")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) pControl->SetEnabled(g_guiSettings.GetInt("videoplayer.adjustrefreshrate") != ADJUST_REFRESHRATE_OFF); - } - else if (strSetting.Equals("videoplayer.synctype")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("videoplayer.usedisplayasclock")); - } - else if (strSetting.Equals("videoplayer.maxspeedadjust")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) - { - bool enabled = (g_guiSettings.GetBool("videoplayer.usedisplayasclock")) && - (g_guiSettings.GetInt("videoplayer.synctype") == SYNC_RESAMPLE); - pControl->SetEnabled(enabled); - } - } - else if (strSetting.Equals("videoplayer.resamplequality")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) - { - bool enabled = (g_guiSettings.GetBool("videoplayer.usedisplayasclock")) && - (g_guiSettings.GetInt("videoplayer.synctype") == SYNC_RESAMPLE); - pControl->SetEnabled(enabled); - } - } - else if (strSetting.Equals("weather.addonsettings")) - { - AddonPtr addon; - if (CAddonMgr::Get().GetAddon(g_guiSettings.GetString("weather.addon"), addon, ADDON_SCRIPT_WEATHER)) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) - pControl->SetEnabled(addon->HasSettings()); - } - } - else if (strSetting.Equals("input.peripherals")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) - pControl->SetEnabled(g_peripherals.GetNumberOfPeripherals() > 0); - } - else if (strSetting.Equals("input.enablejoystick")) - { - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) - pControl->SetEnabled(CPeripheralImon::GetCountOfImonsConflictWithDInput() == 0); - } - } - - g_guiSettings.SetChanged(); - g_guiSettings.NotifyObservers(ObservableMessageGuiSettings); -} - -void CGUIWindowSettingsCategory::OnClick(BaseSettingControlPtr pSettingControl) -{ - CStdString strSetting = pSettingControl->GetSetting()->GetSetting(); - if (strSetting.Equals("weather.addonsettings")) - { - CStdString name = g_guiSettings.GetString("weather.addon"); - AddonPtr addon; - if (CAddonMgr::Get().GetAddon(name, addon, ADDON_SCRIPT_WEATHER)) - { // TODO: maybe have ShowAndGetInput return a bool if settings changed, then only reset weather if true. - CGUIDialogAddonSettings::ShowAndGetInput(addon); - g_weatherManager.Refresh(); - } - } - else if (strSetting.Equals("lookandfeel.rssedit")) - { - AddonPtr addon; - CAddonMgr::Get().GetAddon("script.rss.editor",addon); - if (!addon) - { - if (!CGUIDialogYesNo::ShowAndGetInput(g_localizeStrings.Get(24076), g_localizeStrings.Get(24100),"RSS Editor",g_localizeStrings.Get(24101))) - return; - CAddonInstaller::Get().Install("script.rss.editor", true, "", false); - } - CBuiltins::Execute("RunScript(script.rss.editor)"); - } - else if (pSettingControl->GetSetting()->GetType() == SETTINGS_TYPE_ADDON) - { // prompt for the addon - CSettingAddon *setting = (CSettingAddon *)pSettingControl->GetSetting(); - CStdString addonID = setting->GetData(); - if (CGUIWindowAddonBrowser::SelectAddonID(setting->m_type, addonID, setting->m_type == ADDON_SCREENSAVER || setting->m_type == ADDON_VIZ || setting->m_type == ADDON_SCRIPT_WEATHER) == 1) - setting->SetData(addonID); - else - return; - } - else if (strSetting.Equals("input.peripherals")) - { - CGUIDialogPeripheralManager *dialog = (CGUIDialogPeripheralManager *)g_windowManager.GetWindow(WINDOW_DIALOG_PERIPHERAL_MANAGER); - if (dialog) - dialog->DoModal(); - // refresh settings - UpdateSettings(); - return; - } - - // if OnClick() returns false, the setting hasn't changed or doesn't - // require immediate update - if (!pSettingControl->OnClick()) - { - UpdateSettings(); - if (!pSettingControl->IsDelayed()) - return; - } - - if (pSettingControl->IsDelayed()) - { // delayed setting - m_delayedSetting = pSettingControl; - m_delayedTimer.StartZero(); - } - else - OnSettingChanged(pSettingControl); -} - -void CGUIWindowSettingsCategory::CheckForUpdates() -{ - for (unsigned int i = 0; i < m_vecSettings.size(); i++) - { - BaseSettingControlPtr pSettingControl = m_vecSettings[i]; - if (pSettingControl->NeedsUpdate()) - { - OnSettingChanged(pSettingControl); - pSettingControl->Reset(); - } - } -} - -void CGUIWindowSettingsCategory::OnSettingChanged(BaseSettingControlPtr pSettingControl) -{ - CStdString strSetting = pSettingControl->GetSetting()->GetSetting(); - - // ok, now check the various special things we need to do - if (pSettingControl->GetSetting()->GetType() == SETTINGS_TYPE_ADDON) - { - CSettingAddon *pSettingAddon = (CSettingAddon*)pSettingControl->GetSetting(); - if (pSettingAddon->m_type == ADDON_SKIN) - { - g_application.ReloadSkin(); - } - else if (pSettingAddon->m_type == ADDON_SCRIPT_WEATHER) - { - g_weatherManager.Refresh(); - } - } - else if (strSetting.Equals("musicplayer.visualisation")) - { // new visualisation choosen... - CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting(); - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID()); - if (pControl->GetValue() == 0) - pSettingString->SetData("None"); - else - pSettingString->SetData(pControl->GetCurrentLabel()); - } - else if (strSetting.Equals("debug.showloginfo")) - { - g_advancedSettings.SetDebugMode(g_guiSettings.GetBool("debug.showloginfo")); - } - /*else if (strSetting.Equals("musicfiles.repeat")) - { - g_playlistPlayer.SetRepeat(PLAYLIST_MUSIC_TEMP, g_guiSettings.GetBool("musicfiles.repeat") ? PLAYLIST::REPEAT_ALL : PLAYLIST::REPEAT_NONE); - }*/ - else if (strSetting.Equals("musiclibrary.cleanup")) - { - CMusicDatabase musicdatabase; - musicdatabase.Clean(); - CUtil::DeleteMusicDatabaseDirectoryCache(); - } - else if (strSetting.Equals("videolibrary.cleanup")) - { - if (CGUIDialogYesNo::ShowAndGetInput(313, 333, 0, 0)) - g_application.StartVideoCleanup(); - } - else if (strSetting.Equals("videolibrary.export")) - CBuiltins::Execute("exportlibrary(video)"); - else if (strSetting.Equals("musiclibrary.export")) - CBuiltins::Execute("exportlibrary(music)"); - else if (strSetting.Equals("karaoke.export") ) - { - CContextButtons choices; - choices.Add(1, g_localizeStrings.Get(22034)); - choices.Add(2, g_localizeStrings.Get(22035)); - - int retVal = CGUIDialogContextMenu::ShowAndGetChoice(choices); - if ( retVal > 0 ) - { - CStdString path(CProfilesManager::Get().GetDatabaseFolder()); - VECSOURCES shares; - g_mediaManager.GetLocalDrives(shares); - if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares, g_localizeStrings.Get(661), path, true)) - { - CMusicDatabase musicdatabase; - musicdatabase.Open(); - - if ( retVal == 1 ) - { - URIUtils::AddFileToFolder(path, "karaoke.html", path); - musicdatabase.ExportKaraokeInfo( path, true ); - } - else - { - URIUtils::AddFileToFolder(path, "karaoke.csv", path); - musicdatabase.ExportKaraokeInfo( path, false ); - } - musicdatabase.Close(); - } - } - } - else if (strSetting.Equals("videolibrary.import")) - { - CStdString path; - VECSOURCES shares; - g_mediaManager.GetLocalDrives(shares); - if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares, g_localizeStrings.Get(651) , path)) - { - CVideoDatabase videodatabase; - videodatabase.Open(); - videodatabase.ImportFromXML(path); - videodatabase.Close(); - } - } - else if (strSetting.Equals("musiclibrary.import")) - { - CStdString path; - VECSOURCES shares; - g_mediaManager.GetLocalDrives(shares); - if (CGUIDialogFileBrowser::ShowAndGetFile(shares, "musicdb.xml", g_localizeStrings.Get(651) , path)) - { - CMusicDatabase musicdatabase; - musicdatabase.Open(); - musicdatabase.ImportFromXML(path); - musicdatabase.Close(); - } - } - else if (strSetting.Equals("karaoke.importcsv")) - { - CStdString path(CProfilesManager::Get().GetDatabaseFolder()); - VECSOURCES shares; - g_mediaManager.GetLocalDrives(shares); - if (CGUIDialogFileBrowser::ShowAndGetFile(shares, "karaoke.csv", g_localizeStrings.Get(651) , path)) - { - CMusicDatabase musicdatabase; - musicdatabase.Open(); - musicdatabase.ImportKaraokeInfo(path); - musicdatabase.Close(); - } - } - else if (strSetting.Left(22).Equals("MusicPlayer.ReplayGain")) - { // Update our replaygain settings - ReplayGainSettings &replayGainSettings = CAudioDecoder::GetReplayGainSettings(); - replayGainSettings.iType = g_guiSettings.GetInt("musicplayer.replaygaintype"); - replayGainSettings.iPreAmp = g_guiSettings.GetInt("musicplayer.replaygainpreamp"); - replayGainSettings.iNoGainPreAmp = g_guiSettings.GetInt("musicplayer.replaygainnogainpreamp"); - replayGainSettings.bAvoidClipping = g_guiSettings.GetBool("musicplayer.replaygainavoidclipping"); - } -#ifdef HAS_WEB_SERVER - else if ( strSetting.Equals("services.webserver") || strSetting.Equals("services.webserverport")) - { - if (strSetting.Equals("services.webserverport")) - ValidatePortNumber(pSettingControl, "8080", "80"); - g_application.StopWebServer(); - if (g_guiSettings.GetBool("services.webserver")) - if (!g_application.StartWebServer()) - { - CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33101), "", g_localizeStrings.Get(33100), ""); - g_guiSettings.SetBool("services.webserver", false); - } - } - else if (strSetting.Equals("services.webserverusername") || strSetting.Equals("services.webserverpassword")) - { - g_application.m_WebServer.SetCredentials(g_guiSettings.GetString("services.webserverusername"), g_guiSettings.GetString("services.webserverpassword")); - } -#endif - else if (strSetting.Equals("services.zeroconf")) - { -#ifdef HAS_ZEROCONF - //ifdef zeroconf here because it's only found in guisettings if defined - if(g_guiSettings.GetBool("services.zeroconf")) - { - CZeroconf::GetInstance()->Stop(); - CZeroconf::GetInstance()->Start(); - } -#ifdef HAS_AIRPLAY - else - { - g_application.StopAirplayServer(true); - g_guiSettings.SetBool("services.airplay", false); - CZeroconf::GetInstance()->Stop(); - } -#endif -#endif - } - else if (strSetting.Equals("services.airplay")) - { -#ifdef HAS_AIRPLAY - if (g_guiSettings.GetBool("services.airplay")) - { -#ifdef HAS_ZEROCONF - // AirPlay needs zeroconf - if(!g_guiSettings.GetBool("services.zeroconf")) - { - g_guiSettings.SetBool("services.zeroconf", true); - CZeroconf::GetInstance()->Stop(); - CZeroconf::GetInstance()->Start(); - } -#endif //HAS_ZEROCONF - g_application.StartAirplayServer();//will stop the server before internal - } - else - g_application.StopAirplayServer(true);//will stop the server before internal -#endif//HAS_AIRPLAY - } - else if (strSetting.Equals("network.ipaddress")) - { - if (g_guiSettings.GetInt("network.assignment") == NETWORK_STATIC) - { - CStdString strDefault = g_guiSettings.GetString("network.ipaddress").Left(g_guiSettings.GetString("network.ipaddress").ReverseFind('.'))+".1"; - if (g_guiSettings.GetString("network.gateway").Equals("0.0.0.0")) - g_guiSettings.SetString("network.gateway",strDefault); - if (g_guiSettings.GetString("network.dns").Equals("0.0.0.0")) - g_guiSettings.SetString("network.dns",strDefault); - - } - } - - else if (strSetting.Equals("network.httpproxyport")) - { - ValidatePortNumber(pSettingControl, "8080", "8080", false); - } - else if (strSetting.Equals("videoplayer.calibrate") || strSetting.Equals("videoscreen.guicalibration")) - { // activate the video calibration screen - g_windowManager.ActivateWindow(WINDOW_SCREEN_CALIBRATION); - } - else if (strSetting.Equals("videoscreen.testpattern")) - { // activate the test pattern - g_windowManager.ActivateWindow(WINDOW_TEST_PATTERN); - } - else if (strSetting.Equals("subtitles.height")) - { - if (!CUtil::IsUsingTTFSubtitles()) - { - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID()); - ((CSettingInt *)pSettingControl->GetSetting())->FromString(pControl->GetCurrentLabel()); - } - } - else if (strSetting.Equals("subtitles.font")) - { - CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting(); - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID()); - pSettingString->SetData(pControl->GetCurrentLabel()); - CSetting *pSetting = (CSetting *)g_guiSettings.GetSetting("subtitles.height"); - FillInSubtitleHeights(pSetting, (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID())); - } - else if (strSetting.Equals("subtitles.charset")) - { - CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting(); - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID()); - CStdString newCharset="DEFAULT"; - if (pControl->GetValue()!=0) - newCharset = g_charsetConverter.getCharsetNameByLabel(pControl->GetCurrentLabel()); - if (newCharset != "" && (newCharset != pSettingString->GetData() || newCharset=="DEFAULT")) - { - pSettingString->SetData(newCharset); - g_charsetConverter.reset(); - } - } - else if (strSetting.Equals("karaoke.fontheight")) - { - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID()); - ((CSettingInt *)pSettingControl->GetSetting())->FromString(pControl->GetCurrentLabel()); - } - else if (strSetting.Equals("karaoke.font")) - { - CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting(); - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID()); - pSettingString->SetData(pControl->GetCurrentLabel()); - CSetting *pSetting = (CSetting *)g_guiSettings.GetSetting("karaoke.fontheight"); - FillInSubtitleHeights(pSetting, (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID())); - } - else if (strSetting.Equals("karaoke.charset")) - { - CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting(); - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID()); - CStdString newCharset="DEFAULT"; - if (pControl->GetValue()!=0) - newCharset = g_charsetConverter.getCharsetNameByLabel(pControl->GetCurrentLabel()); - if (newCharset != "" && (newCharset != pSettingString->GetData() || newCharset=="DEFAULT")) - { - pSettingString->SetData(newCharset); - g_charsetConverter.reset(); - } - } - else if (strSetting.Equals("locale.charset")) - { - CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting(); - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID()); - CStdString newCharset="DEFAULT"; - if (pControl->GetValue()!=0) - newCharset = g_charsetConverter.getCharsetNameByLabel(pControl->GetCurrentLabel()); - if (newCharset != "" && (newCharset != pSettingString->GetData() || newCharset=="DEFAULT")) - { - pSettingString->SetData(newCharset); - g_charsetConverter.reset(); - } - } - else if (strSetting.Equals("lookandfeel.font")) - { // new font choosen... - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID()); - CStdString strSkinFontSet = m_SkinFontSetIDs[pControl->GetCurrentLabel()]; - if (strSkinFontSet != ".svn" && strSkinFontSet != g_guiSettings.GetString("lookandfeel.font")) - { - g_guiSettings.SetString("lookandfeel.font", strSkinFontSet); - g_application.ReloadSkin(); - } - } - else if (strSetting.Equals("lookandfeel.soundskin")) - { // new sound skin choosen... - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID()); - if (pControl->GetValue()==0) - g_guiSettings.SetString("lookandfeel.soundskin", "OFF"); - else if (pControl->GetValue()==1) - g_guiSettings.SetString("lookandfeel.soundskin", "SKINDEFAULT"); - else - g_guiSettings.SetString("lookandfeel.soundskin", pControl->GetCurrentLabel()); - - g_audioManager.Enable(true); - g_audioManager.Load(); - } - else if (strSetting.Equals("lookandfeel.skinsettings")) - { - g_windowManager.ActivateWindow(WINDOW_SKIN_SETTINGS); - } - else if (strSetting.Equals("input.enablemouse")) - { - g_Mouse.SetEnabled(g_guiSettings.GetBool("input.enablemouse")); - } - else if (strSetting.Equals("input.enablejoystick")) - { -#if defined(HAS_SDL_JOYSTICK) - g_Joystick.SetEnabled(g_guiSettings.GetBool("input.enablejoystick") - && CPeripheralImon::GetCountOfImonsConflictWithDInput() == 0); -#endif - } - else if (strSetting.Equals("videoscreen.screen")) - { - DisplayMode mode = g_guiSettings.GetInt("videoscreen.screen"); - // Cascade - FillInResolutions("videoscreen.resolution", mode, RES_DESKTOP, true); - } - else if (strSetting.Equals("videoscreen.resolution")) - { - RESOLUTION nextRes = (RESOLUTION) g_guiSettings.GetInt("videoscreen.resolution"); - // Cascade - FillInRefreshRates("videoscreen.screenmode", nextRes, true); - } - else if (strSetting.Equals("videoscreen.screenmode")) - { - int iControlID = pSettingControl->GetID(); - CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), iControlID); - g_windowManager.SendMessage(msg); - RESOLUTION nextRes = (RESOLUTION)msg.GetParam1(); - - OnRefreshRateChanged(nextRes); - } - else if (strSetting.Equals("videoscreen.vsync")) - { - int iControlID = pSettingControl->GetID(); - CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), iControlID); - g_windowManager.SendMessage(msg); -// DXMERGE: This may be useful -// g_videoConfig.SetVSyncMode((VSYNC)msg.GetParam1()); - } - else if (strSetting.Equals("videoscreen.fakefullscreen")) - { - if (g_graphicsContext.IsFullScreenRoot()) - g_graphicsContext.SetVideoResolution(g_graphicsContext.GetVideoResolution(), true); - } - else if (strSetting.Equals("locale.audiolanguage")) - { // new audio language chosen... - CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting(); - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID()); - int iLanguage = pControl->GetValue(); - if (iLanguage < 2) - { - if (iLanguage < 1) - g_guiSettings.SetString(strSetting, "original"); - else - g_guiSettings.SetString(strSetting, "default"); - g_langInfo.SetAudioLanguage(""); - } - else - { - CStdString strLanguage = pControl->GetCurrentLabel(); - if (strLanguage != pSettingString->GetData()) - { - g_guiSettings.SetString(strSetting, strLanguage); - g_langInfo.SetAudioLanguage(strLanguage); - } - } - } - else if (strSetting.Equals("locale.subtitlelanguage")) - { // new subtitle language chosen... - CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting(); - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID()); - int iLanguage = pControl->GetValue(); - if (iLanguage < 2) - { - if (iLanguage < 1) - g_guiSettings.SetString(strSetting, "original"); - else - g_guiSettings.SetString(strSetting, "default"); - g_langInfo.SetSubtitleLanguage(""); - } - else - { - CStdString strLanguage = pControl->GetCurrentLabel(); - if (strLanguage != pSettingString->GetData()) - { - g_guiSettings.SetString(strSetting, strLanguage); - g_langInfo.SetSubtitleLanguage(strLanguage); - } - } - } - else if (strSetting.Equals("locale.language")) - { // new language chosen... - CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting(); - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID()); - CStdString strLanguage = pControl->GetCurrentLabel(); - if (strLanguage != ".svn" && strLanguage != pSettingString->GetData()) - g_application.SetLanguage(strLanguage); - - // user set language, no longer use the TV's language - vector cecDevices; - if (g_peripherals.GetPeripheralsWithFeature(cecDevices, FEATURE_CEC) > 0) - { - for (vector::iterator it = cecDevices.begin(); it != cecDevices.end(); it++) - (*it)->SetSetting("use_tv_menu_language", false); - } - } - else if (strSetting.Equals("lookandfeel.skintheme")) - { //a new Theme was chosen - CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting(); - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID()); - - CStdString strSkinTheme; - - if (pControl->GetValue() == 0) // Use default theme - strSkinTheme = "SKINDEFAULT"; - else - strSkinTheme = pControl->GetCurrentLabel(); - - if (strSkinTheme != pSettingString->GetData()) - { - g_guiSettings.SetString("lookandfeel.skintheme", strSkinTheme); - // also set the default color theme - CStdString colorTheme(URIUtils::ReplaceExtension(strSkinTheme, ".xml")); - if (colorTheme.Equals("Textures.xml")) - colorTheme = "defaults.xml"; - g_guiSettings.SetString("lookandfeel.skincolors", colorTheme); - g_application.ReloadSkin(); - } - } - else if (strSetting.Equals("lookandfeel.skincolors")) - { //a new color was chosen - CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting(); - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID()); - - CStdString strSkinColor; - - if (pControl->GetValue() == 0) // Use default colors - strSkinColor = "SKINDEFAULT"; - else - strSkinColor = pControl->GetCurrentLabel() + ".xml"; - - if (strSkinColor != pSettingString->GetData()) - { - g_guiSettings.SetString("lookandfeel.skincolors", strSkinColor); - g_application.ReloadSkin(); - } - } - else if (strSetting.Equals("videoplayer.displayresolution")) - { - CSettingInt *pSettingInt = (CSettingInt *)pSettingControl->GetSetting(); - int iControlID = pSettingControl->GetID(); - CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), iControlID); - g_windowManager.SendMessage(msg); - pSettingInt->SetData(msg.GetParam1()); - } - else if (strSetting.Equals("videoscreen.flickerfilter") || strSetting.Equals("videoscreen.soften")) - { // reset display - g_graphicsContext.SetVideoResolution(CDisplaySettings::Get().GetCurrentResolution()); - } - else if (strSetting.Equals("screensaver.preview")) - { - g_application.ActivateScreenSaver(true); - } - else if (strSetting.Equals("screensaver.settings")) - { - AddonPtr addon; - if (CAddonMgr::Get().GetAddon(g_guiSettings.GetString("screensaver.mode"), addon, ADDON_SCREENSAVER)) - CGUIDialogAddonSettings::ShowAndGetInput(addon); - } - else if (strSetting.Equals("debug.screenshotpath") || strSetting.Equals("audiocds.recordingpath") || strSetting.Equals("subtitles.custompath") || strSetting.Equals("pvrmenu.iconpath")) - { - CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting(); - CStdString path = g_guiSettings.GetString(strSetting,false); - VECSOURCES shares; - - bool bWriteOnly = true; - - if (strSetting.Equals("pvrmenu.iconpath")) - { - bWriteOnly = false; - } - else if (strSetting.Equals("subtitles.custompath")) - { - bWriteOnly = false; - shares = *CMediaSourceSettings::Get().GetSources("video"); - } - - g_mediaManager.GetNetworkLocations(shares); - g_mediaManager.GetLocalDrives(shares); - - UpdateSettings(); - - if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares, g_localizeStrings.Get(pSettingString->m_iHeadingString), path, bWriteOnly)) - { - pSettingString->SetData(path); - } - } - else if (strSetting.Left(22).Equals("MusicPlayer.ReplayGain")) - { // Update our replaygain settings - ReplayGainSettings &replayGainSettings = CAudioDecoder::GetReplayGainSettings(); - replayGainSettings.iType = g_guiSettings.GetInt("musicplayer.replaygaintype"); - replayGainSettings.iPreAmp = g_guiSettings.GetInt("musicplayer.replaygainpreamp"); - replayGainSettings.iNoGainPreAmp = g_guiSettings.GetInt("musicplayer.replaygainnogainpreamp"); - replayGainSettings.bAvoidClipping = g_guiSettings.GetBool("musicplayer.replaygainavoidclipping"); - } - else if (strSetting.Equals("locale.country")) - { - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID()); - - const CStdString& strRegion=pControl->GetCurrentLabel(); - g_langInfo.SetCurrentRegion(strRegion); - g_guiSettings.SetString("locale.country", strRegion); - g_weatherManager.Refresh(); // need to reset our weather, as temperatures need re-translating. - } - else if (strSetting.Equals("smb.winsserver") || strSetting.Equals("smb.workgroup") ) - { - if (g_guiSettings.GetString("smb.winsserver") == "0.0.0.0") - g_guiSettings.SetString("smb.winsserver", ""); - - /* okey we really don't need to restarat, only deinit samba, but that could be damn hard if something is playing*/ - //TODO - General way of handling setting changes that require restart - - if (CGUIDialogYesNo::ShowAndGetInput(14038, 14039, 14040, -1, -1)) - { - g_settings.Save(); - CApplicationMessenger::Get().RestartApp(); - } - } - else if (strSetting.Equals("services.upnpserver")) - { -#ifdef HAS_UPNP - if (g_guiSettings.GetBool("services.upnpserver")) - g_application.StartUPnPServer(); - else - g_application.StopUPnPServer(); -#endif - } - else if (strSetting.Equals("services.upnprenderer")) - { -#ifdef HAS_UPNP - if (g_guiSettings.GetBool("services.upnprenderer")) - g_application.StartUPnPRenderer(); - else - g_application.StopUPnPRenderer(); -#endif - } - else if (strSetting.Equals("services.upnpcontroller")) - { -#ifdef HAS_UPNP - g_application.StopUPnPClient(); /* always stop and restart */ - if (g_guiSettings.GetBool("services.upnpcontroller")) - g_application.StartUPnPClient(); -#endif - } - else if (strSetting.Equals("services.esenabled")) - { -#ifdef HAS_EVENT_SERVER - if (g_guiSettings.GetBool("services.esenabled")) - { - if (!g_application.StartEventServer()) - { - CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33102), "", g_localizeStrings.Get(33100), ""); - g_guiSettings.SetBool("services.esenabled", false); - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) pControl->SetEnabled(false); - } - } - else - { - if (!g_application.StopEventServer(true, true)) - { - g_guiSettings.SetBool("services.esenabled", true); - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) pControl->SetEnabled(true); - } - } -#endif -#ifdef HAS_JSONRPC - if (g_guiSettings.GetBool("services.esenabled")) - { - if (!g_application.StartJSONRPCServer()) - CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33103), "", g_localizeStrings.Get(33100), ""); - } - else - g_application.StopJSONRPCServer(false); -#endif - } - else if (strSetting.Equals("services.esport")) - { -#ifdef HAS_EVENT_SERVER - ValidatePortNumber(pSettingControl, "9777", "9777"); - //restart eventserver without asking user - if (g_application.StopEventServer(true, false)) - { - if (!g_application.StartEventServer()) - CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33102), "", g_localizeStrings.Get(33100), ""); - } -#if defined(TARGET_DARWIN_OSX) - //reconfigure XBMCHelper for port changes - XBMCHelper::GetInstance().Configure(); -#endif -#endif - } - else if (strSetting.Equals("services.esallinterfaces")) - { -#ifdef HAS_EVENT_SERVER - if (g_guiSettings.GetBool("services.esenabled")) - { - if (g_application.StopEventServer(true, true)) - { - if (!g_application.StartEventServer()) - CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33102), "", g_localizeStrings.Get(33100), ""); - } - else - { - g_guiSettings.SetBool("services.esenabled", true); - CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID()); - if (pControl) pControl->SetEnabled(true); - } - } -#endif -#ifdef HAS_JSONRPC - if (g_guiSettings.GetBool("services.esenabled")) - { - if (!g_application.StartJSONRPCServer()) - CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33103), "", g_localizeStrings.Get(33100), ""); - } - else - g_application.StopJSONRPCServer(false); -#endif - } - else if (strSetting.Equals("services.esinitialdelay") || - strSetting.Equals("services.escontinuousdelay")) - { -#ifdef HAS_EVENT_SERVER - if (g_guiSettings.GetBool("services.esenabled")) - { - g_application.RefreshEventServer(); - } -#endif - } - else if (strSetting.Equals("pvrmanager.enabled")) - { - if (g_guiSettings.GetBool("pvrmanager.enabled")) - CApplicationMessenger::Get().ExecBuiltIn("XBMC.StartPVRManager", false); - else - CApplicationMessenger::Get().ExecBuiltIn("XBMC.StopPVRManager", false); - } - else if (strSetting.Equals("masterlock.lockcode")) - { - // Now Prompt User to enter the old and then the new MasterCode! - if(g_passwordManager.SetMasterLockMode()) - { - // We asked for the master password and saved the new one! - // Nothing todo here - } - } - else if (strSetting.Equals("network.interface")) - { - NetworkInterfaceChanged(); - } -#ifdef HAS_LINUX_NETWORK - else if (strSetting.Equals("network.save")) - { - NetworkAssignment iAssignment; - CStdString sIPAddress; - CStdString sNetworkMask; - CStdString sDefaultGateway; - CStdString sWirelessNetwork; - CStdString sWirelessKey; - CStdString sDns; - EncMode iWirelessEnc; - CStdString ifaceName; - - CGUISpinControlEx *ifaceControl = (CGUISpinControlEx *)GetControl(GetSetting("network.interface")->GetID()); - ifaceName = ifaceControl->GetLabel(); - CNetworkInterface* iface = g_application.getNetwork().GetInterfaceByName(ifaceName); - - // Update controls with information - CGUISpinControlEx* pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.assignment")->GetID()); - if (pControl1) iAssignment = (NetworkAssignment) pControl1->GetValue(); - CGUIButtonControl* pControl2 = (CGUIButtonControl *)GetControl(GetSetting("network.ipaddress")->GetID()); - if (pControl2) sIPAddress = pControl2->GetLabel2(); - pControl2 = (CGUIButtonControl *)GetControl(GetSetting("network.subnet")->GetID()); - if (pControl2) sNetworkMask = pControl2->GetLabel2(); - pControl2 = (CGUIButtonControl *)GetControl(GetSetting("network.gateway")->GetID()); - if (pControl2) sDefaultGateway = pControl2->GetLabel2(); - pControl2 = (CGUIButtonControl *)GetControl(GetSetting("network.dns")->GetID()); - if (pControl2) sDns = pControl2->GetLabel2(); - pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.enc")->GetID()); - if (pControl1) iWirelessEnc = (EncMode) pControl1->GetValue(); - pControl2 = (CGUIButtonControl *)GetControl(GetSetting("network.essid")->GetID()); - if (pControl2) sWirelessNetwork = pControl2->GetLabel2(); - pControl2 = (CGUIButtonControl *)GetControl(GetSetting("network.key")->GetID()); - if (pControl2) sWirelessKey = pControl2->GetLabel2(); - - CGUIDialogProgress* pDlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); - pDlgProgress->SetLine(0, ""); - pDlgProgress->SetLine(1, g_localizeStrings.Get(784)); - pDlgProgress->SetLine(2, ""); - pDlgProgress->StartModal(); - pDlgProgress->Progress(); - - std::vector nameServers; - nameServers.push_back(sDns); - g_application.getNetwork().SetNameServers(nameServers); - iface->SetSettings(iAssignment, sIPAddress, sNetworkMask, sDefaultGateway, sWirelessNetwork, sWirelessKey, iWirelessEnc); - - pDlgProgress->Close(); - - if (iAssignment == NETWORK_DISABLED) - CGUIDialogOK::ShowAndGetInput(0, 788, 0, 0); - else if (iface->IsConnected()) - CGUIDialogOK::ShowAndGetInput(0, 785, 0, 0); - else - CGUIDialogOK::ShowAndGetInput(0, 786, 0, 0); - } - else if (strSetting.Equals("network.essid")) - { - CGUIDialogAccessPoints *dialog = (CGUIDialogAccessPoints *)g_windowManager.GetWindow(WINDOW_DIALOG_ACCESS_POINTS); - if (dialog) - { - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting("network.interface")->GetID()); - dialog->SetInterfaceName(pControl->GetLabel()); - dialog->DoModal(); - - if (dialog->WasItemSelected()) - { - CGUIButtonControl* pControl2 = (CGUIButtonControl *)GetControl(GetSetting("network.essid")->GetID()); - if (pControl2) pControl2->SetLabel2(dialog->GetSelectedAccessPointEssId()); - pControl = (CGUISpinControlEx *)GetControl(GetSetting("network.enc")->GetID()); - if (pControl) pControl->SetValue(dialog->GetSelectedAccessPointEncMode()); - } - } - } -#endif -#ifdef _LINUX - else if (strSetting.Equals("locale.timezonecountry")) - { - CGUISpinControlEx *pControlCountry = (CGUISpinControlEx *)GetControl(pSettingControl->GetID()); - CStdString country = pControlCountry->GetCurrentLabel(); - - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting("locale.timezone")->GetID()); - pControl->Clear(); - vector timezones = g_timezone.GetTimezonesByCountry(country); - for (unsigned int i=0; i < timezones.size(); i++) - { - pControl->AddLabel(timezones[i], i); - } - - g_timezone.SetTimezone(pControl->GetLabel()); - g_guiSettings.SetString("locale.timezonecountry",pControlCountry->GetLabel().c_str()); - - CGUISpinControlEx *tzControl = (CGUISpinControlEx *)GetControl(GetSetting("locale.timezone")->GetID()); - g_guiSettings.SetString("locale.timezone", tzControl->GetLabel().c_str()); - - CDateTime::ResetTimezoneBias(); - } - else if (strSetting.Equals("locale.timezone")) - { - CGUISpinControlEx *tzControl = (CGUISpinControlEx *)GetControl(GetSetting("locale.timezone")->GetID()); - g_timezone.SetTimezone(tzControl->GetLabel()); - g_guiSettings.SetString("locale.timezone", tzControl->GetLabel().c_str()); - - tzControl = (CGUISpinControlEx *)GetControl(GetSetting("locale.timezonecountry")->GetID()); - g_guiSettings.SetString("locale.timezonecountry", tzControl->GetLabel().c_str()); - - CDateTime::ResetTimezoneBias(); - } -#endif - else if (strSetting.Equals("lookandfeel.skinzoom")) - { - g_windowManager.SendMessage(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_WINDOW_RESIZE); - } - else if (strSetting.Equals("videolibrary.flattentvshows") || - strSetting.Equals("videolibrary.removeduplicates") || - strSetting.Equals("videolibrary.groupmoviesets")) - { - CUtil::DeleteVideoDatabaseDirectoryCache(); - } - else if (strSetting.Equals("pvrmenu.searchicons") && g_PVRManager.IsStarted()) - { - g_PVRManager.SearchMissingChannelIcons(); - } - else if (strSetting.Equals("pvrmanager.resetdb")) - { - if (g_PVRManager.CheckParentalPIN(g_localizeStrings.Get(19262).c_str()) && - CGUIDialogYesNo::ShowAndGetInput(19098, 19186, 750, 0)) - { - CDateTime::ResetTimezoneBias(); - g_PVRManager.ResetDatabase(false); - } - } - else if (strSetting.Equals("epg.resetepg")) - { - if (CGUIDialogYesNo::ShowAndGetInput(19098, 19188, 750, 0)) - { - CDateTime::ResetTimezoneBias(); - g_PVRManager.ResetDatabase(true); - } - } - else if (strSetting.Equals("pvrmanager.channelscan") && g_PVRManager.IsStarted()) - { - if (CGUIDialogYesNo::ShowAndGetInput(19098, 19118, 19194, 0)) - g_PVRManager.StartChannelScan(); - } - else if (strSetting.Equals("pvrmanager.channelmanager") && g_PVRManager.IsStarted()) - { - CGUIDialogPVRChannelManager *dialog = (CGUIDialogPVRChannelManager *)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_CHANNEL_MANAGER); - if (dialog) - { - dialog->DoModal(); - } - } - else if (strSetting.Equals("pvrclient.menuhook") && g_PVRManager.IsStarted()) - { - g_PVRManager.Get().Clients()->ProcessMenuHooks(-1, PVR_MENUHOOK_SETTING); - } - else if (strSetting.compare(0, 12, "audiooutput.") == 0) - { - if (strSetting.Equals("audiooutput.audiodevice")) - { - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID()); -#if defined(TARGET_DARWIN) - // save the sinkname - since we don't have sinks on osx - // we need to get the fitting sinkname for the device label from the - // factory - std::string label2sink = pControl->GetCurrentLabel(); - CAEFactory::VerifyOutputDevice(label2sink, false); - g_guiSettings.SetString("audiooutput.audiodevice", label2sink.c_str()); -#else - g_guiSettings.SetString("audiooutput.audiodevice", m_AnalogAudioSinkMap[pControl->GetCurrentLabel()]); -#endif - } -#if !defined(TARGET_DARWIN) - else if (strSetting.Equals("audiooutput.passthroughdevice")) - { - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID()); - g_guiSettings.SetString("audiooutput.passthroughdevice", m_DigitalAudioSinkMap[pControl->GetCurrentLabel()]); - } -#endif - else if (strSetting.Equals("audiooutput.guisoundmode")) - { - CAEFactory::SetSoundMode(g_guiSettings.GetInt("audiooutput.guisoundmode")); - } - - CAEFactory::OnSettingsChange(strSetting); - } - else if (strSetting.Equals("pvrparental.enabled")) - { - if (g_guiSettings.GetBool("pvrparental.enabled") && g_guiSettings.GetString("pvrparental.pin").GetLength() == 0) - { - CStdString newPassword = ""; - bool bNewPassword = CGUIDialogNumeric::ShowAndVerifyNewPassword(newPassword); - if (bNewPassword) - { - // password set... save it - g_guiSettings.SetString("pvrparental.pin", newPassword); - } - else - { - // password not set... disable parental - g_guiSettings.SetBool("pvrparental.enabled", false); - } - } - } - - UpdateSettings(); -} - -void CGUIWindowSettingsCategory::FreeControls() -{ - // clear the category group - CGUIControlGroupList *control = (CGUIControlGroupList *)GetControl(CATEGORY_GROUP_ID); - if (control) - { - control->FreeResources(); - control->ClearAll(); - } - m_vecSections.clear(); - FreeSettingsControls(); -} - -void CGUIWindowSettingsCategory::FreeSettingsControls() -{ - // clear the settings group - CGUIControlGroupList *control = (CGUIControlGroupList *)GetControl(SETTINGS_GROUP_ID); - if (control) - { - control->FreeResources(); - control->ClearAll(); - } - - for (int i = 0; (size_t)i < m_vecSettings.size(); i++) - m_vecSettings[i]->Clear(); - - m_vecSettings.clear(); -} - -CGUIControl* CGUIWindowSettingsCategory::AddSetting(CSetting *pSetting, float width, int &iControlID) -{ - if (!pSetting->IsVisible()) return NULL; // not displayed in current session - BaseSettingControlPtr pSettingControl; - CGUIControl *pControl = NULL; - if (pSetting->GetControlType() == CHECKMARK_CONTROL) - { - pControl = new CGUIRadioButtonControl(*m_pOriginalRadioButton); - if (!pControl) return NULL; - ((CGUIRadioButtonControl *)pControl)->SetLabel(g_localizeStrings.Get(pSetting->GetLabel())); - pControl->SetWidth(width); - pSettingControl.reset(new CGUIRadioButtonSettingControl((CGUIRadioButtonControl *)pControl, iControlID, pSetting)); - } - else if (pSetting->GetControlType() == SPIN_CONTROL_FLOAT || pSetting->GetControlType() == SPIN_CONTROL_INT_PLUS || pSetting->GetControlType() == SPIN_CONTROL_TEXT || pSetting->GetControlType() == SPIN_CONTROL_INT) - { - pControl = new CGUISpinControlEx(*m_pOriginalSpin); - if (!pControl) return NULL; - pControl->SetWidth(width); - ((CGUISpinControlEx *)pControl)->SetText(g_localizeStrings.Get(pSetting->GetLabel())); - pSettingControl.reset(new CGUISpinExSettingControl((CGUISpinControlEx *)pControl, iControlID, pSetting)); - } - else if (pSetting->GetControlType() == SEPARATOR_CONTROL && m_pOriginalImage) - { - pControl = new CGUIImage(*m_pOriginalImage); - if (!pControl) return NULL; - pControl->SetWidth(width); - pSettingControl.reset(new CGUISeparatorSettingControl((CGUIImage *)pControl, iControlID, pSetting)); - } - else if (pSetting->GetControlType() == EDIT_CONTROL_INPUT || - pSetting->GetControlType() == EDIT_CONTROL_HIDDEN_INPUT || - pSetting->GetControlType() == EDIT_CONTROL_MD5_INPUT || - pSetting->GetControlType() == EDIT_CONTROL_NUMBER_INPUT || - pSetting->GetControlType() == EDIT_CONTROL_IP_INPUT || - pSetting->GetControlType() == EDIT_CONTROL_HIDDEN_NUMBER_VERIFY_NEW ) - { - pControl = new CGUIEditControl(*m_pOriginalEdit); - if (!pControl) return NULL; - ((CGUIEditControl *)pControl)->SetLabel(g_localizeStrings.Get(pSetting->GetLabel())); - pControl->SetWidth(width); - pSettingControl.reset(new CGUIEditSettingControl((CGUIEditControl *)pControl, iControlID, pSetting)); - } - else if (pSetting->GetControlType() != SEPARATOR_CONTROL) // button control - { - pControl = new CGUIButtonControl(*m_pOriginalButton); - if (!pControl) return NULL; - ((CGUIButtonControl *)pControl)->SetLabel(g_localizeStrings.Get(pSetting->GetLabel())); - pControl->SetWidth(width); - pSettingControl.reset(new CGUIButtonSettingControl((CGUIButtonControl *)pControl, iControlID, pSetting)); - } - if (!pControl) - { - pSettingControl.reset(); - return NULL; - } - pControl->SetID(iControlID++); - pControl->SetVisible(true); - CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(SETTINGS_GROUP_ID); - if (group) - { - pControl->AllocResources(); - group->AddControl(pControl); - } - m_vecSettings.push_back(pSettingControl); - return pControl; -} - -void CGUIWindowSettingsCategory::FrameMove() -{ - if (m_delayedSetting && m_delayedTimer.GetElapsedMilliseconds() > 3000) - { // we send a thread message so that it's processed the following frame (some settings won't - // like being changed during Render()) - CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), GetID()); - g_windowManager.SendThreadMessage(message, GetID()); - m_delayedTimer.Stop(); - } - CGUIWindow::FrameMove(); -} - -void CGUIWindowSettingsCategory::DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions) -{ - // update alpha status of current button - bool bAlphaFaded = false; - CGUIControl *control = GetFirstFocusableControl(CONTROL_START_BUTTONS + m_iSection); - if (control && !control->HasFocus()) - { - if (control->GetControlType() == CGUIControl::GUICONTROL_BUTTON) - { - control->SetFocus(true); - ((CGUIButtonControl *)control)->SetAlpha(0x80); - bAlphaFaded = true; - } - else if (control->GetControlType() == CGUIControl::GUICONTROL_TOGGLEBUTTON) - { - control->SetFocus(true); - ((CGUIButtonControl *)control)->SetSelected(true); - bAlphaFaded = true; - } - } - CGUIWindow::DoProcess(currentTime, dirtyregions); - if (bAlphaFaded) - { - control->SetFocus(false); - if (control->GetControlType() == CGUIControl::GUICONTROL_BUTTON) - ((CGUIButtonControl *)control)->SetAlpha(0xFF); - else - ((CGUIButtonControl *)control)->SetSelected(false); - } -} - -void CGUIWindowSettingsCategory::Render() -{ - CGUIWindow::Render(); -} - -void CGUIWindowSettingsCategory::FillInSubtitleHeights(CSetting *pSetting, CGUISpinControlEx *pControl) -{ - CSettingInt *pSettingInt = (CSettingInt*)pSetting; - pControl->SetType(SPIN_CONTROL_TYPE_TEXT); - pControl->Clear(); - if (CUtil::IsUsingTTFSubtitles()) - { // easy - just fill as per usual - CStdString strLabel; - for (int i = pSettingInt->m_iMin; i <= pSettingInt->m_iMax; i += pSettingInt->m_iStep) - { - if (pSettingInt->m_iFormat > -1) - { - CStdString strFormat = g_localizeStrings.Get(pSettingInt->m_iFormat); - strLabel.Format(strFormat, i); - } - else - strLabel.Format(pSettingInt->m_strFormat, i); - pControl->AddLabel(strLabel, i); - } - pControl->SetValue(pSettingInt->GetData()); - } -} - -void CGUIWindowSettingsCategory::FillInSubtitleFonts(CSetting *pSetting) -{ - CSettingString *pSettingString = (CSettingString*)pSetting; - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID()); - pControl->SetType(SPIN_CONTROL_TYPE_TEXT); - pControl->Clear(); - int iCurrentFont = 0; - int iFont = 0; - - // find TTF fonts - { - CFileItemList items; - CFileItemList items2; - CDirectory::GetDirectory("special://home/media/Fonts/", items2); - - if (CDirectory::GetDirectory("special://xbmc/media/Fonts/", items)) - { - items.Append(items2); - for (int i = 0; i < items.Size(); ++i) - { - CFileItemPtr pItem = items[i]; - - if (!pItem->m_bIsFolder) - { - - if ( !URIUtils::GetExtension(pItem->GetLabel()).Equals(".ttf") ) continue; - if (pItem->GetLabel().Equals(pSettingString->GetData(), false)) - iCurrentFont = iFont; - - pControl->AddLabel(pItem->GetLabel(), iFont++); - } - - } - } + case SettingDependencyTypeNone: + default: + break; } - pControl->SetValue(iCurrentFont); } -void CGUIWindowSettingsCategory::FillInSkinFonts(CSetting *pSetting) +void CGUIWindowSettingsCategory::CreateSettings() { - BaseSettingControlPtr setting = GetSetting(pSetting->GetSetting()); - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(setting->GetID()); - pControl->SetType(SPIN_CONTROL_TYPE_TEXT); - pControl->Clear(); - setting->SetDelayed(); + FreeSettingsControls(); - m_SkinFontSetIDs.clear(); - int iSkinFontSet = 0; + if (m_categories.size() <= 0) + return; - CStdString strPath = g_SkinInfo->GetSkinPath("Font.xml"); + if (m_iCategory < 0 || m_iCategory >= (int)m_categories.size()) + m_iCategory = 0; - CXBMCTinyXML xmlDoc; - if (!xmlDoc.LoadFile(strPath)) - { - CLog::Log(LOGERROR, "Couldn't load %s", strPath.c_str()); - return ; - } + CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(SETTINGS_GROUP_ID); + if (group == NULL) + return; - TiXmlElement* pRootElement = xmlDoc.RootElement(); + const CSettingCategory* category = m_categories.at(m_iCategory); + if (category == NULL) + return; - CStdString strValue = pRootElement->Value(); - if (strValue != CStdString("fonts")) - { - CLog::Log(LOGERROR, "file %s doesnt start with ", strPath.c_str()); - return ; - } + std::set settingMap; - const TiXmlNode *pChild = pRootElement->FirstChild(); - strValue = pChild->Value(); - if (strValue == "fontset") + const SettingGroupList& groups = category->GetGroups(CViewStateSettings::Get().GetSettingLevel()); + int iControlID = CONTROL_START_CONTROL; + bool first = true; + for (SettingGroupList::const_iterator groupIt = groups.begin(); groupIt != groups.end(); groupIt++) { - while (pChild) - { - strValue = pChild->Value(); - if (strValue == "fontset") - { - const char* idAttr = ((TiXmlElement*) pChild)->Attribute("id"); - const char* idLocAttr = ((TiXmlElement*) pChild)->Attribute("idloc"); - const char* unicodeAttr = ((TiXmlElement*) pChild)->Attribute("unicode"); - - bool isUnicode=(unicodeAttr && stricmp(unicodeAttr, "true") == 0); - - bool isAllowed=true; - if (g_langInfo.ForceUnicodeFont() && !isUnicode) - isAllowed=false; + if (*groupIt == NULL) + continue; - if (idAttr != NULL && isAllowed) - { - if (idLocAttr) - { - pControl->AddLabel(g_localizeStrings.Get(atoi(idLocAttr)), iSkinFontSet); - m_SkinFontSetIDs[g_localizeStrings.Get(atoi(idLocAttr))] = idAttr; - } - else - { - pControl->AddLabel(idAttr, iSkinFontSet); - m_SkinFontSetIDs[idAttr] = idAttr; - } - if (strcmpi(idAttr, g_guiSettings.GetString("lookandfeel.font").c_str()) == 0) - pControl->SetValue(iSkinFontSet); - iSkinFontSet++; - } - } - pChild = pChild->NextSibling(); - } + const SettingList& settings = (*groupIt)->GetSettings(CViewStateSettings::Get().GetSettingLevel()); + if (settings.size() <= 0) + continue; - } - else - { - // Since no fontset is defined, there is no selection of a fontset, so disable the component - pControl->AddLabel(g_localizeStrings.Get(13278), 1); - pControl->SetValue(1); - pControl->SetEnabled(false); - } -} + if (first) + first = false; + else + AddSeparator(group->GetWidth(), iControlID); -void CGUIWindowSettingsCategory::FillInSoundSkins(CSetting *pSetting) -{ - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID()); - pControl->SetType(SPIN_CONTROL_TYPE_TEXT); - pControl->Clear(); - pControl->SetShowRange(true); - - //find skins... - CFileItemList items; - CDirectory::GetDirectory("special://xbmc/sounds/", items); - CDirectory::GetDirectory("special://home/sounds/", items); - - int iCurrentSoundSkin = 0; - int iSoundSkin = 0; - vector vecSoundSkins; - int i; - for (i = 0; i < items.Size(); ++i) - { - CFileItemPtr pItem = items[i]; - if (pItem->m_bIsFolder) + for (SettingList::const_iterator settingIt = settings.begin(); settingIt != settings.end(); settingIt++) { - if (strcmpi(pItem->GetLabel().c_str(), ".svn") == 0) continue; - if (strcmpi(pItem->GetLabel().c_str(), "fonts") == 0) continue; - if (strcmpi(pItem->GetLabel().c_str(), "media") == 0) continue; - vecSoundSkins.push_back(pItem->GetLabel()); - } - } + CSetting *pSetting = *settingIt; + settingMap.insert(pSetting->GetId()); + CGUIControl* pControl = AddSetting(pSetting, group->GetWidth(), iControlID); - pControl->AddLabel(g_localizeStrings.Get(474), iSoundSkin++); // Off - pControl->AddLabel(g_localizeStrings.Get(15109), iSoundSkin++); // Skin Default - - if (g_guiSettings.GetString("lookandfeel.soundskin")=="SKINDEFAULT") - iCurrentSoundSkin=1; - - sort(vecSoundSkins.begin(), vecSoundSkins.end(), sortstringbyname()); - for (i = 0; i < (int) vecSoundSkins.size(); ++i) - { - CStdString strSkin = vecSoundSkins[i]; - if (strcmpi(strSkin.c_str(), g_guiSettings.GetString("lookandfeel.soundskin").c_str()) == 0) - { - iCurrentSoundSkin = iSoundSkin; + FillControl(pSetting, pControl); } - pControl->AddLabel(strSkin, iSoundSkin++); - } - pControl->SetValue(iCurrentSoundSkin); - return ; -} - -void CGUIWindowSettingsCategory::FillInCharSets(CSetting *pSetting) -{ - CSettingString *pSettingString = (CSettingString*)pSetting; - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID()); - pControl->SetType(SPIN_CONTROL_TYPE_TEXT); - pControl->Clear(); - int iCurrentCharset = 0; - vector vecCharsets = g_charsetConverter.getCharsetLabels(); - - CStdString strCurrentCharsetLabel="DEFAULT"; - if (pSettingString->GetData()!="DEFAULT") - strCurrentCharsetLabel = g_charsetConverter.getCharsetLabelByName(pSettingString->GetData()); - - sort(vecCharsets.begin(), vecCharsets.end(), sortstringbyname()); - - vecCharsets.insert(vecCharsets.begin(), g_localizeStrings.Get(13278)); // "Default" - - bool bIsAuto=(pSettingString->GetData()=="DEFAULT"); - - for (int i = 0; i < (int) vecCharsets.size(); ++i) - { - CStdString strCharsetLabel = vecCharsets[i]; - - if (!bIsAuto && strCharsetLabel == strCurrentCharsetLabel) - iCurrentCharset = i; - - pControl->AddLabel(strCharsetLabel, i); } - pControl->SetValue(iCurrentCharset); + if (settingMap.size() > 0) + m_settings.RegisterCallback(this, settingMap); + + // update our settings (turns controls on/off as appropriate) + UpdateSettings(); } -DisplayMode CGUIWindowSettingsCategory::FillInScreens(CStdString strSetting, RESOLUTION res) +void CGUIWindowSettingsCategory::UpdateSettings() { - DisplayMode mode; - if (res == RES_WINDOW) - mode = DM_WINDOWED; - else - mode = CDisplaySettings::Get().GetResolutionInfo(res).iScreen; - - // we expect "videoscreen.screen" but it might be hidden on some platforms, - // so check that we actually have a visable control. - BaseSettingControlPtr control = GetSetting(strSetting); - if (control) + for (vector::iterator it = m_settingControls.begin(); it != m_settingControls.end(); it++) { - control->SetDelayed(); - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(control->GetID()); - pControl->Clear(); - - CStdString strScreen; - if (g_advancedSettings.m_canWindowed) - pControl->AddLabel(g_localizeStrings.Get(242), -1); + BaseSettingControlPtr pSettingControl = *it; + CSetting *pSetting = pSettingControl->GetSetting(); + CGUIControl *pControl = pSettingControl->GetControl(); + if (pSetting == NULL || pControl == NULL) + continue; - for (int idx = 0; idx < g_Windowing.GetNumScreens(); idx++) + // update the setting's control's state (enabled/disabled etc) + const SettingDependencies &deps = pSetting->GetDependencies(); + for (SettingDependencies::const_iterator dep = deps.begin(); dep != deps.end(); dep++) { - strScreen.Format(g_localizeStrings.Get(241), CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP + idx).iScreen + 1); - pControl->AddLabel(strScreen, CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP + idx).iScreen); + // don't check "update" dependencies here as all the controls are already + // setup properly based on the existing values + if (dep->GetType() == SettingDependencyTypeUpdate) + continue; + + CheckDependency(pSettingControl, *dep); } - pControl->SetValue(mode); - g_guiSettings.SetInt("videoscreen.screen", mode); - } - return mode; + pSettingControl->Update(); + } } -void CGUIWindowSettingsCategory::FillInResolutions(CStdString strSetting, DisplayMode mode, RESOLUTION res, bool UserChange) +CGUIControl* CGUIWindowSettingsCategory::AddSetting(CSetting *pSetting, float width, int &iControlID) { - BaseSettingControlPtr control = GetSetting(strSetting); - control->SetDelayed(); - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(control->GetID()); - - pControl->Clear(); + if (pSetting == NULL) + return NULL; - RESOLUTION spinres = RES_INVALID; // index of the resolution in the spinner that has same screen/width/height as res + BaseSettingControlPtr pSettingControl; + CGUIControl *pControl = NULL; - if (mode == DM_WINDOWED) - { - pControl->AddLabel(g_localizeStrings.Get(242), RES_WINDOW); - spinres = RES_WINDOW; - } - else + switch (pSetting->GetControl().GetType()) { - vector resolutions = g_Windowing.ScreenResolutions(mode); - - for (unsigned int idx = 0; idx < resolutions.size(); idx++) + case SettingControlTypeCheckmark: { - CStdString strRes; - strRes.Format("%dx%d%s", resolutions[idx].width, resolutions[idx].height, - (resolutions[idx].interlaced == D3DPRESENTFLAG_INTERLACED) ? "i" : "p"); - pControl->AddLabel(strRes, resolutions[idx].ResInfo_Index); - - RESOLUTION_INFO res1 = CDisplaySettings::Get().GetResolutionInfo(res); - RESOLUTION_INFO res2 = CDisplaySettings::Get().GetResolutionInfo(resolutions[idx].ResInfo_Index); - if ( res1.iScreen == res2.iScreen - && res1.iScreenWidth == res2.iScreenWidth - && res1.iScreenHeight == res2.iScreenHeight - && (res1.dwFlags & D3DPRESENTFLAG_INTERLACED) == (res2.dwFlags & D3DPRESENTFLAG_INTERLACED)) - spinres = (RESOLUTION) resolutions[idx].ResInfo_Index; - } - } + pControl = new CGUIRadioButtonControl(*m_pOriginalRadioButton); + if (pControl == NULL) + return NULL; - if (UserChange) - { - // Auto-select the windowed or desktop resolution of the screen - int autoresolution = RES_DESKTOP; - if (mode == DM_WINDOWED) - { - autoresolution = RES_WINDOW; + ((CGUIRadioButtonControl *)pControl)->SetLabel(g_localizeStrings.Get(pSetting->GetLabel())); + pSettingControl.reset(new CGUIControlRadioButtonSetting((CGUIRadioButtonControl *)pControl, iControlID, pSetting)); + break; } - else + + case SettingControlTypeSpinner: { - for (int idx=0; idx < g_Windowing.GetNumScreens(); idx++) - if (CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP + idx).iScreen == mode) - { - autoresolution = RES_DESKTOP + idx; - break; - } - } - pControl->SetValue(autoresolution); - - // Cascade - FillInRefreshRates("videoscreen.screenmode", (RESOLUTION) autoresolution, true); - } - else - { - // select the entry equivalent to the resolution passed by the res parameter - pControl->SetValue(spinres); - } -} - -void CGUIWindowSettingsCategory::FillInRefreshRates(CStdString strSetting, RESOLUTION res, bool UserChange) -{ - // The only meaningful parts of res here are iScreen, iScreenWidth, iScreenHeight - - vector refreshrates; - if (res > RES_WINDOW) - refreshrates = g_Windowing.RefreshRates(CDisplaySettings::Get().GetResolutionInfo(res).iScreen, - CDisplaySettings::Get().GetResolutionInfo(res).iScreenWidth, - CDisplaySettings::Get().GetResolutionInfo(res).iScreenHeight, - CDisplaySettings::Get().GetResolutionInfo(res).dwFlags); - - // The control setting doesn't exist when not in standalone mode, don't manipulate it - BaseSettingControlPtr control = GetSetting(strSetting); - CGUISpinControlEx *pControl= NULL; - - // Populate - if (control) - { - control->SetDelayed(); - pControl = (CGUISpinControlEx *)GetControl(control->GetID()); - pControl->Clear(); + pControl = new CGUISpinControlEx(*m_pOriginalSpin); + if (pControl == NULL) + return NULL; - if (res == RES_WINDOW) - { - pControl->AddLabel(g_localizeStrings.Get(242), RES_WINDOW); + ((CGUISpinControlEx *)pControl)->SetText(g_localizeStrings.Get(pSetting->GetLabel())); + pSettingControl.reset(new CGUIControlSpinExSetting((CGUISpinControlEx *)pControl, iControlID, pSetting)); + break; } - else + + case SettingControlTypeEdit: { - for (unsigned int idx = 0; idx < refreshrates.size(); idx++) - { - CStdString strRR; - strRR.Format("%.02f", refreshrates[idx].RefreshRate); - pControl->AddLabel(strRR, refreshrates[idx].ResInfo_Index); - } + pControl = new CGUIEditControl(*m_pOriginalEdit); + if (pControl == NULL) + return NULL; + + ((CGUIEditControl *)pControl)->SetLabel(g_localizeStrings.Get(pSetting->GetLabel())); + pSettingControl.reset(new CGUIControlEditSetting((CGUIEditControl *)pControl, iControlID, pSetting)); + break; } - } - - // Select a rate - if (UserChange) - { - RESOLUTION newresolution; - if (res == RES_WINDOW) - newresolution = RES_WINDOW; - else - newresolution = (RESOLUTION) g_Windowing.DefaultRefreshRate(CDisplaySettings::Get().GetResolutionInfo(res).iScreen, refreshrates).ResInfo_Index; - - if (pControl) - pControl->SetValue(newresolution); - - OnRefreshRateChanged(newresolution); - } - else - { - if (pControl) - pControl->SetValue(res); - } -} - -void CGUIWindowSettingsCategory::OnRefreshRateChanged(RESOLUTION nextRes) -{ - RESOLUTION lastRes = g_graphicsContext.GetVideoResolution(); - bool cancelled = false; - - CDisplaySettings::Get().SetCurrentResolution(nextRes, true); - g_graphicsContext.SetVideoResolution(nextRes); - - if (!CGUIDialogYesNo::ShowAndGetInput(13110, 13111, 20022, 20022, -1, -1, cancelled, 10000)) - { - CDisplaySettings::Get().SetCurrentResolution(lastRes, true); - g_graphicsContext.SetVideoResolution(lastRes); - - DisplayMode mode = FillInScreens("videoscreen.screen", lastRes); - FillInResolutions("videoscreen.resolution", mode, lastRes, false); - FillInRefreshRates("videoscreen.screenmode", lastRes, false); - } -} - -void CGUIWindowSettingsCategory::FillInLanguages(CSetting *pSetting, const std::vector &languages /* = std::vector() */, const std::vector &languageKeys /* = std::vector() */) -{ - CSettingString *pSettingString = (CSettingString *)pSetting; - BaseSettingControlPtr setting = GetSetting(pSetting->GetSetting()); - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(setting->GetID()); - pControl->Clear(); - - //find languages... - CFileItemList items; - CDirectory::GetDirectory("special://xbmc/language/", items); - - int iCurrentLang = 0; - vector vecLanguage; - for (int i = 0; i < items.Size(); ++i) - { - CFileItemPtr pItem = items[i]; - if (pItem->m_bIsFolder) + + case SettingControlTypeButton: { - if (strcmpi(pItem->GetLabel().c_str(), ".svn") == 0) continue; - if (strcmpi(pItem->GetLabel().c_str(), "fonts") == 0) continue; - if (strcmpi(pItem->GetLabel().c_str(), "media") == 0) continue; - vecLanguage.push_back(pItem->GetLabel()); + pControl = new CGUIButtonControl(*m_pOriginalButton); + if (pControl == NULL) + return NULL; + + ((CGUIButtonControl *)pControl)->SetLabel(g_localizeStrings.Get(pSetting->GetLabel())); + pSettingControl.reset(new CGUIControlButtonSetting((CGUIButtonControl *)pControl, iControlID, pSetting)); + break; } + + case SettingControlTypeNone: + default: + return NULL; } - sort(vecLanguage.begin(), vecLanguage.end(), sortstringbyname()); - // Add language options passed by parameter at the beginning - if (languages.size() > 0) - vecLanguage.insert(vecLanguage.begin(), languages.begin(), languages.begin() + languages.size()); - for (unsigned int i = 0; i < vecLanguage.size(); ++i) - { - CStdString strLanguage = vecLanguage[i]; - if ((i < languageKeys.size() && strcmpi(languageKeys[i].c_str(), pSettingString->GetData().c_str()) == 0) || - strcmpi(strLanguage.c_str(), pSettingString->GetData().c_str()) == 0) - iCurrentLang = i; - pControl->AddLabel(strLanguage, i); - } + if (pSetting->GetControl().GetDelayed()) + pSettingControl->SetDelayed(); - pControl->SetValue(iCurrentLang); + return AddSettingControl(pControl, pSettingControl, width, iControlID); } -void CGUIWindowSettingsCategory::FillInRegions(CSetting *pSetting) +CGUIControl* CGUIWindowSettingsCategory::AddSeparator(float width, int &iControlID) { - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID()); - pControl->SetType(SPIN_CONTROL_TYPE_TEXT); - pControl->Clear(); - - int iCurrentRegion=0; - CStdStringArray regions; - g_langInfo.GetRegionNames(regions); - - CStdString strCurrentRegion=g_langInfo.GetCurrentRegion(); - - sort(regions.begin(), regions.end(), sortstringbyname()); - - for (int i = 0; i < (int) regions.size(); ++i) - { - const CStdString& strRegion = regions[i]; - - if (strRegion == strCurrentRegion) - iCurrentRegion = i; - - pControl->AddLabel(strRegion, i); - } - - pControl->SetValue(iCurrentRegion); -} + if (m_pOriginalImage == NULL) + return NULL; -BaseSettingControlPtr CGUIWindowSettingsCategory::GetSetting(const CStdString &strSetting) -{ - for (unsigned int i = 0; i < m_vecSettings.size(); i++) - { - if (m_vecSettings[i]->GetSetting()->GetSetting() == strSetting) - return m_vecSettings[i]; - } - return BaseSettingControlPtr(); -} + CGUIControl *pControl = new CGUIImage(*m_pOriginalImage); + if (pControl == NULL) + return NULL; -void CGUIWindowSettingsCategory::FillInSkinThemes(CSetting *pSetting) -{ - // There is a default theme (just Textures.xpr/xbt) - // any other *.xpr|*.xbt files are additional themes on top of this one. - CSettingString *pSettingString = (CSettingString *)pSetting; - BaseSettingControlPtr setting = GetSetting(pSetting->GetSetting()); - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(setting->GetID()); - CStdString strSettingString = g_guiSettings.GetString("lookandfeel.skintheme"); - setting->SetDelayed(); - - // Clear and add. the Default Label - pControl->Clear(); - pControl->SetShowRange(true); - pControl->AddLabel(g_localizeStrings.Get(15109), 0); // "SKINDEFAULT" The standard Textures.xpr/xbt will be used - - CStdString strDefaultTheme = pSettingString->GetData(); - - // Search for Themes in the Current skin! - vector vecTheme; - CUtil::GetSkinThemes(vecTheme); - - // Remove the extension from the current Theme (backward compat) - URIUtils::RemoveExtension(strSettingString); - - // Sort the Themes for GUI and list them - int iCurrentTheme = 0; - for (int i = 0; i < (int) vecTheme.size(); ++i) - { - CStdString strTheme = vecTheme[i]; - // Is the Current Theme our Used Theme! If yes set the ID! - if (strTheme.CompareNoCase(strSettingString) == 0 ) - iCurrentTheme = i + 1; // 1: #of Predefined Theme [Label] - pControl->AddLabel(strTheme, i + 1); - } - // Set the Choosen Theme - pControl->SetValue(iCurrentTheme); + return AddSettingControl(pControl, BaseSettingControlPtr(new CGUIControlSeparatorSetting((CGUIImage *)pControl, iControlID)), width, iControlID); } -void CGUIWindowSettingsCategory::FillInSkinColors(CSetting *pSetting) +CGUIControl* CGUIWindowSettingsCategory::AddSettingControl(CGUIControl *pControl, BaseSettingControlPtr pSettingControl, float width, int &iControlID) { - // There is a default theme (just defaults.xml) - // any other *.xml files are additional color themes on top of this one. - BaseSettingControlPtr setting = GetSetting(pSetting->GetSetting()); - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(setting->GetID()); - CStdString strSettingString = g_guiSettings.GetString("lookandfeel.skincolors"); - setting->SetDelayed(); - - // Clear and add. the Default Label - pControl->Clear(); - pControl->SetShowRange(true); - pControl->AddLabel(g_localizeStrings.Get(15109), 0); // "SKINDEFAULT"! The standard defaults.xml will be used! - - // Search for colors in the Current skin! - vector vecColors; - - CStdString strPath; - URIUtils::AddFileToFolder(g_SkinInfo->Path(),"colors",strPath); - - CFileItemList items; - CDirectory::GetDirectory(CSpecialProtocol::TranslatePathConvertCase(strPath), items, ".xml"); - // Search for Themes in the Current skin! - for (int i = 0; i < items.Size(); ++i) + if (pControl == NULL) { - CFileItemPtr pItem = items[i]; - if (!pItem->m_bIsFolder && pItem->GetLabel().CompareNoCase("defaults.xml") != 0) - { // not the default one - CStdString strLabel = pItem->GetLabel(); - vecColors.push_back(strLabel.Mid(0, strLabel.size() - 4)); - } + pSettingControl.reset(); + return NULL; } - sort(vecColors.begin(), vecColors.end(), sortstringbyname()); - - // Remove the .xml extension from the Themes - if (URIUtils::GetExtension(strSettingString) == ".xml") - URIUtils::RemoveExtension(strSettingString); - - int iCurrentColor = 0; - for (int i = 0; i < (int) vecColors.size(); ++i) + + pControl->SetID(iControlID++); + pControl->SetVisible(true); + pControl->SetWidth(width); + + CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(SETTINGS_GROUP_ID); + if (group != NULL) { - CStdString strColor = vecColors[i]; - // Is the Current Theme our Used Theme! If yes set the ID! - if (strColor.CompareNoCase(strSettingString) == 0 ) - iCurrentColor = i + 1; // 1: #of Predefined Theme [Label] - pControl->AddLabel(strColor, i + 1); + pControl->AllocResources(); + group->AddControl(pControl); } - // Set the Choosen Theme - pControl->SetValue(iCurrentColor); + m_settingControls.push_back(pSettingControl); + + return pControl; } -void CGUIWindowSettingsCategory::FillInStartupWindow(CSetting *pSetting) +void CGUIWindowSettingsCategory::OnClick(BaseSettingControlPtr pSettingControl) { - CSettingInt *pSettingInt = (CSettingInt*)pSetting; - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID()); - pControl->Clear(); - - const vector &startupWindows = g_SkinInfo->GetStartupWindows(); - - // TODO: How should we localize this? - // In the long run there is no way to do it really without the skin having some - // translation information built in to it, which isn't really feasible. - - // Alternatively we could lookup the strings in the english strings file to get - // their id and then get the string from that + std::string strSetting = pSettingControl->GetSetting()->GetId(); - // easier would be to have the skinner use the "name" as the label number. - - // eg 513 - - bool currentSettingFound(false); - for (vector::const_iterator it = startupWindows.begin(); it != startupWindows.end(); it++) + // we need to first set the delayed setting and then execute OnClick() + // because OnClick() triggers OnSettingChanged() and there we need to + // know if the changed setting is delayed or not + if (pSettingControl->IsDelayed()) { - CStdString windowName((*it).m_name); - if (StringUtils::IsNaturalNumber(windowName)) - windowName = g_localizeStrings.Get(atoi(windowName.c_str())); - int windowID((*it).m_id); - pControl->AddLabel(windowName, windowID); - if (pSettingInt->GetData() == windowID) - currentSettingFound = true; - } + m_delayedSetting = pSettingControl; + if (m_delayedTimer.IsRunning()) + m_delayedTimer.Restart(); + else + m_delayedTimer.Start(SETTING_DELAY); - // ok, now check whether our current option is one of these - // and set it's value - if (!currentSettingFound) - { // nope - set it to the "default" option - the first one - pSettingInt->SetData(startupWindows[0].m_id); + return; } - pControl->SetValue(pSettingInt->GetData()); -} - -void CGUIWindowSettingsCategory::OnInitWindow() -{ - m_strOldTrackFormat = g_guiSettings.GetString("musicfiles.trackformat"); - m_strOldTrackFormatRight = g_guiSettings.GetString("musicfiles.trackformatright"); - SetupControls(); - CGUIWindow::OnInitWindow(); -} -void CGUIWindowSettingsCategory::FillInViewModes(CSetting *pSetting, int windowID) -{ - CSettingInt *pSettingInt = (CSettingInt*)pSetting; - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID()); - pControl->AddLabel("Auto", DEFAULT_VIEW_AUTO); - bool found(false); - int foundType = 0; - CGUIWindow *window = g_windowManager.GetWindow(windowID); - if (window) - { - window->Initialize(); - for (int i = 50; i < 60; i++) - { - IGUIContainer *control = (IGUIContainer *)window->GetControl(i); - if (control) - { - int type = (control->GetType() << 16) | i; - pControl->AddLabel(control->GetLabel(), type); - if (type == pSettingInt->GetData()) - found = true; - else if ((type >> 16) == (pSettingInt->GetData() >> 16)) - foundType = type; - } - } - window->ClearAll(); - } - if (!found) - pSettingInt->SetData(foundType ? foundType : (DEFAULT_VIEW_AUTO)); - pControl->SetValue(pSettingInt->GetData()); + // if changing the setting fails + // we need to restore the proper state + if (!pSettingControl->OnClick()) + pSettingControl->Update(); } -void CGUIWindowSettingsCategory::FillInSortMethods(CSetting *pSetting, int windowID) +CSettingSection* CGUIWindowSettingsCategory::GetSection(int windowID) const { - CSettingInt *pSettingInt = (CSettingInt*)pSetting; - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID()); - CFileItemList items("C:"); - CGUIViewState *state = CGUIViewState::GetViewState(windowID, items); - if (state) + for (size_t index = 0; index < SettingGroupSize; index++) { - bool found(false); - vector< pair > sortMethods; - state->GetSortMethods(sortMethods); - for (unsigned int i = 0; i < sortMethods.size(); i++) - { - pControl->AddLabel(g_localizeStrings.Get(sortMethods[i].second), sortMethods[i].first); - if (sortMethods[i].first == pSettingInt->GetData()) - found = true; - } - if (!found && sortMethods.size()) - pSettingInt->SetData(sortMethods[0].first); + if (s_settingGroupMap[index].id == windowID) + return m_settings.GetSection(s_settingGroupMap[index].name); } - pControl->SetValue(pSettingInt->GetData()); - delete state; + + return NULL; } -void CGUIWindowSettingsCategory::FillInNetworkInterfaces(CSetting *pSetting, float groupWidth, int &iControlID) +BaseSettingControlPtr CGUIWindowSettingsCategory::GetSettingControl(const std::string &strSetting) { - CGUISpinControlEx *pControl = (CGUISpinControlEx *)AddSetting(pSetting, groupWidth, iControlID); - pControl->Clear(); - - // query list of interfaces - vector vecInterfaces; - std::vector& ifaces = g_application.getNetwork().GetInterfaceList(); - std::vector::const_iterator iter = ifaces.begin(); - while (iter != ifaces.end()) + for (vector::iterator control = m_settingControls.begin(); control != m_settingControls.end(); control++) { - CNetworkInterface* iface = *iter; - vecInterfaces.push_back(iface->GetName()); - ++iter; + if ((*control)->GetSetting() != NULL && (*control)->GetSetting()->GetId() == strSetting) + return *control; } - sort(vecInterfaces.begin(), vecInterfaces.end(), sortstringbyname()); - int iInterface = 0; - for (unsigned int i = 0; i < vecInterfaces.size(); ++i) - pControl->AddLabel(vecInterfaces[i], iInterface++); + return BaseSettingControlPtr(); } -void CGUIWindowSettingsCategory::FillInEpgGuideView(CSetting *pSetting) +BaseSettingControlPtr CGUIWindowSettingsCategory::GetSettingControl(int controlId) { - CSettingInt *pSettingInt = (CSettingInt*)pSetting; - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID()); - pControl->Clear(); + if (controlId < CONTROL_START_CONTROL || controlId >= (int)(CONTROL_START_CONTROL + m_settingControls.size())) + return BaseSettingControlPtr(); - pControl->AddLabel(g_localizeStrings.Get(19029), GUIDE_VIEW_CHANNEL); - pControl->AddLabel(g_localizeStrings.Get(19030), GUIDE_VIEW_NOW); - pControl->AddLabel(g_localizeStrings.Get(19031), GUIDE_VIEW_NEXT); - pControl->AddLabel(g_localizeStrings.Get(19032), GUIDE_VIEW_TIMELINE); - - pControl->SetValue(pSettingInt->GetData()); + return m_settingControls[controlId - CONTROL_START_CONTROL]; } -void CGUIWindowSettingsCategory::FillInPvrStartLastChannel(CSetting *pSetting) +void CGUIWindowSettingsCategory::FillControl(CSetting *pSetting, CGUIControl *pSettingControl) { - CSettingInt *pSettingInt = (CSettingInt*)pSetting; - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID()); - pControl->Clear(); + void *filler = CSettings::Get().GetSettingOptionsFiller(pSetting); + if (filler == NULL) + return; - pControl->AddLabel(g_localizeStrings.Get(106), START_LAST_CHANNEL_OFF); - pControl->AddLabel(g_localizeStrings.Get(19190), START_LAST_CHANNEL_MIN); - pControl->AddLabel(g_localizeStrings.Get(107), START_LAST_CHANNEL_ON); + if (pSetting->GetType() == SettingTypeInteger) + { + CSettingInt *pSettingInt = (CSettingInt*)pSetting; - pControl->SetValue(pSettingInt->GetData()); -} + // get the list of options and the current option + IntegerSettingOptions options; + int currentOption = pSettingInt->GetValue(); + ((IntegerSettingOptionsFiller)filler)(pSetting, options, currentOption); -void CGUIWindowSettingsCategory::FillInAudioDevices(CSetting* pSetting, bool Passthrough) -{ - CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID()); - pControl->Clear(); + // clear the spinner control + CGUISpinControlEx *pSpinControl = (CGUISpinControlEx *)pSettingControl; + pSpinControl->Clear(); - CStdString currentDevice = Passthrough ? g_guiSettings.GetString("audiooutput.passthroughdevice") : g_guiSettings.GetString("audiooutput.audiodevice"); + // fill the spinner control + for (IntegerSettingOptions::const_iterator option = options.begin(); option != options.end(); option++) + pSpinControl->AddLabel(option->first, option->second); - if (Passthrough) - { - m_DigitalAudioSinkMap.clear(); - m_DigitalAudioSinkMap["Error - no devices found"] = "null:"; - } - else - { - m_AnalogAudioSinkMap.clear(); - m_AnalogAudioSinkMap["Error - no devices found"] = "null:"; - } + // set the current option + pSpinControl->SetValue(currentOption); - int selectedValue = -1; - AEDeviceList sinkList; - CAEFactory::EnumerateOutputDevices(sinkList, Passthrough); -#if !defined(TARGET_DARWIN) - if (sinkList.size()==0) - { - pControl->AddLabel("Error - no devices found", 0); - selectedValue = 0; + // check if the current setting has changed + if (currentOption != pSettingInt->GetValue()) + pSettingInt->SetValue(currentOption); } - else + else if (pSetting->GetType() == SettingTypeString) { -#endif - AEDeviceList::const_iterator iter = sinkList.begin(); - for (int i=0; iter != sinkList.end(); iter++) - { - CStdString label = (*iter).first; - CStdString sink = (*iter).second; - pControl->AddLabel(label.c_str(), i); - - if (currentDevice.Equals(sink)) - selectedValue = i; - - if (Passthrough) - m_DigitalAudioSinkMap[label] = sink; - else - m_AnalogAudioSinkMap[label] = sink; + CSettingString *pSettingString = (CSettingString*)pSetting; - i++; - } + // get the list of options and the current option + StringSettingOptions options; + std::string currentOption = pSettingString->GetValue(); + ((StringSettingOptionsFiller)filler)(pSetting, options, currentOption); -#if !defined(TARGET_DARWIN) - } -#endif + // clear the spinner control + CGUISpinControlEx *pSpinControl = (CGUISpinControlEx *)pSettingControl; + pSpinControl->Clear(); - if (selectedValue < 0) - { - CLog::Log(LOGWARNING, "Failed to find previously selected audio sink"); - pControl->SetValue(0); - if (!Passthrough) - ((CSettingString*)pSetting)->SetData(m_AnalogAudioSinkMap[pControl->GetCurrentLabel()]); - else - ((CSettingString*)pSetting)->SetData(m_DigitalAudioSinkMap[pControl->GetCurrentLabel()]); - } - else - pControl->SetValue(selectedValue); -} + // fill the spinner control + for (StringSettingOptions::const_iterator option = options.begin(); option != options.end(); option++) + pSpinControl->AddLabel(option->first, option->second); -void CGUIWindowSettingsCategory::NetworkInterfaceChanged(void) -{ -#if 0 - NetworkAssignment iAssignment; - CStdString sIPAddress; - CStdString sNetworkMask; - CStdString sDefaultGateway; - CStdString sWirelessNetwork; - CStdString sWirelessKey; - EncMode iWirelessEnc; - bool bIsWireless; - CStdString ifaceName; - - // Get network information - CGUISpinControlEx *ifaceControl = (CGUISpinControlEx *)GetControl(GetSetting("network.interface")->GetID()); - ifaceName = ifaceControl->GetLabel(); - CNetworkInterface* iface = g_application.getNetwork().GetInterfaceByName(ifaceName); - iface->GetSettings(iAssignment, sIPAddress, sNetworkMask, sDefaultGateway, sWirelessNetwork, sWirelessKey, iWirelessEnc); - bIsWireless = iface->IsWireless(); - - CStdString dns; - std::vector dnss = g_application.getNetwork().GetNameServers(); - if (dnss.size() >= 1) - dns = dnss[0]; - - // Update controls with information - CGUISpinControlEx* pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.assignment")->GetID()); - if (pControl1) pControl1->SetValue(iAssignment); - GetSetting("network.dns")->GetSetting()->FromString(dns); - if (iAssignment == NETWORK_STATIC || iAssignment == NETWORK_DISABLED) - { - GetSetting("network.ipaddress")->GetSetting()->FromString(sIPAddress); - GetSetting("network.subnet")->GetSetting()->FromString(sNetworkMask); - GetSetting("network.gateway")->GetSetting()->FromString(sDefaultGateway); - } - else - { - GetSetting("network.ipaddress")->GetSetting()->FromString(iface->GetCurrentIPAddress()); - GetSetting("network.subnet")->GetSetting()->FromString(iface->GetCurrentNetmask()); - GetSetting("network.gateway")->GetSetting()->FromString(iface->GetCurrentDefaultGateway()); - } - - pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.enc")->GetID()); - if (pControl1) pControl1->SetValue(iWirelessEnc); - - if (bIsWireless) - { - GetSetting("network.essid")->GetSetting()->FromString(sWirelessNetwork); - GetSetting("network.key")->GetSetting()->FromString(sWirelessKey); - } - else - { - GetSetting("network.essid")->GetSetting()->FromString(""); - GetSetting("network.key")->GetSetting()->FromString(""); - } -#endif -} + // set the current option + pSpinControl->SetStringValue(currentOption); -void CGUIWindowSettingsCategory::ValidatePortNumber(BaseSettingControlPtr pSettingControl, const CStdString& userPort, const CStdString& privPort, bool listening/*=true*/) -{ - CSettingString *pSetting = (CSettingString *)pSettingControl->GetSetting(); - // check that it's a valid port - int port = atoi(pSetting->GetData().c_str()); -#ifdef _LINUX - if (listening && !CUtil::CanBindPrivileged() && (port < 1024 || port > 65535)) - { - CGUIDialogOK::ShowAndGetInput(257, 850, 852, -1); - pSetting->SetData(userPort.c_str()); - } - else -#endif - if (port <= 0 || port > 65535) - { - CGUIDialogOK::ShowAndGetInput(257, 850, 851, -1); - pSetting->SetData(privPort.c_str()); + // check if the current setting has changed + if (currentOption.compare(pSettingString->GetValue()) != 0) + pSettingString->SetValue(currentOption); } } diff --git a/xbmc/settings/windows/GUIWindowSettingsCategory.h b/xbmc/settings/windows/GUIWindowSettingsCategory.h index 74b222ca73eb4..2e8b3551f56f8 100644 --- a/xbmc/settings/windows/GUIWindowSettingsCategory.h +++ b/xbmc/settings/windows/GUIWindowSettingsCategory.h @@ -1,7 +1,7 @@ #pragma once /* - * Copyright (C) 2005-2013 Team XBMC + * Copyright (C) 2005-2012 Team XBMC * http://www.xbmc.org * * This Program is free software; you can redistribute it and/or modify @@ -20,92 +20,96 @@ * */ -#include "guilib/GUIWindow.h" -#include "settings/GUISettings.h" -#include "settings/windows/GUISettingControls.h" -#include "utils/Stopwatch.h" - -typedef boost::shared_ptr BaseSettingControlPtr; +#include -class CGUIWindowSettingsCategory : - public CGUIWindow +#include "GUIControlSettings.h" +#include "guilib/GUIWindow.h" +#include "settings/SettingDependency.h" +#include "settings/SettingSection.h" +#include "settings/Settings.h" +#include "settings/SettingsManager.h" +#include "threads/Timer.h" + +typedef boost::shared_ptr BaseSettingControlPtr; + +class CGUIWindowSettingsCategory + : public CGUIWindow, + protected ITimerCallback, + protected ISettingCallback { public: CGUIWindowSettingsCategory(void); virtual ~CGUIWindowSettingsCategory(void); virtual bool OnMessage(CGUIMessage &message); + virtual bool OnAction(const CAction &action); virtual bool OnBack(int actionID); - virtual void FrameMove(); - virtual void Render(); virtual void DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions); - virtual int GetID() const { return CGUIWindow::GetID() + m_iScreen; }; + virtual int GetID() const { return CGUIWindow::GetID() + m_iSection; }; protected: virtual void OnInitWindow(); + virtual void OnWindowLoaded(); + + virtual void SetupControls(bool createSettings = true); + virtual void FreeControls(); + void FreeSettingsControls(); - void CheckNetworkSettings(); - void FillInSubtitleHeights(CSetting *pSetting, CGUISpinControlEx *pControl); - void FillInSubtitleFonts(CSetting *pSetting); - void FillInCharSets(CSetting *pSetting); - void FillInSkinFonts(CSetting *pSetting); - void FillInSoundSkins(CSetting *pSetting); - void FillInLanguages(CSetting *pSetting, const std::vector &languages = std::vector(), const std::vector &languageKeys = std::vector()); - DisplayMode FillInScreens(CStdString strSetting, RESOLUTION res); - void FillInResolutions(CStdString strSetting, DisplayMode mode, RESOLUTION res, bool UserChange); - void FillInRefreshRates(CStdString strSetting, RESOLUTION res, bool UserChange); - void OnRefreshRateChanged(RESOLUTION resolution); - void FillInRegions(CSetting *pSetting); - void FillInStartupWindow(CSetting *pSetting); - void FillInViewModes(CSetting *pSetting, int windowID); - void FillInSortMethods(CSetting *pSetting, int windowID); - void FillInEpgGuideView(CSetting *pSetting); - void FillInPvrStartLastChannel(CSetting *pSetting); - - void FillInSkinThemes(CSetting *pSetting); - void FillInSkinColors(CSetting *pSetting); - - void FillInNetworkInterfaces(CSetting *pSetting, float groupWidth, int &iControlID); - void NetworkInterfaceChanged(void); - - void FillInAudioDevices(CSetting* pSetting, bool Passthrough = false); - - virtual void SetupControls(); - CGUIControl* AddIntBasedSpinControl(CSetting *pSetting, float groupWidth, int &iControlID); + virtual void OnTimeout(); + virtual void OnSettingChanged(const CSetting *setting); + + void UpdateControl(const std::string &dependingSetting, const CSettingDependency &dependency); + void CheckDependency(BaseSettingControlPtr pSettingControl, const CSettingDependency &dependency); + void CreateSettings(); void UpdateSettings(); - void CheckForUpdates(); - void FreeSettingsControls(); - virtual void FreeControls(); - virtual void OnClick(BaseSettingControlPtr pSettingControl); - virtual void OnSettingChanged(BaseSettingControlPtr pSettingControl); CGUIControl* AddSetting(CSetting *pSetting, float width, int &iControlID); - BaseSettingControlPtr GetSetting(const CStdString &strSetting); + CGUIControl* AddSeparator(float width, int &iControlID); + CGUIControl* AddSettingControl(CGUIControl *pControl, BaseSettingControlPtr pSettingControl, float width, int &iControlID); + + /*! + \brief A setting control has been interacted with by the user + + This method is called when the user manually interacts (clicks, + edits) with a setting control. It contains handling for both + delayed and undelayed settings and either starts the delay timer + or triggers the setting change which, on success, results in a + callback to OnSettingChanged(). + + \param pSettingControl Setting control that has been interacted with + */ + virtual void OnClick(BaseSettingControlPtr pSettingControl); + + /* TODO + void OnRefreshRateChanged(RESOLUTION resolution); + + void FillInResolutions(CStdString strSetting, DisplayMode mode, RESOLUTION res, bool UserChange); + void FillInRefreshRates(CStdString strSetting, RESOLUTION res, bool UserChange); + */ - void ValidatePortNumber(BaseSettingControlPtr pSettingControl, const CStdString& userPort, const CStdString& privPort, bool listening=true); + CSettingSection* GetSection(int windowID) const; + BaseSettingControlPtr GetSettingControl(const std::string &setting); + BaseSettingControlPtr GetSettingControl(int controlId); - std::vector m_vecSettings; + void FillControl(CSetting *pSetting, CGUIControl *pSettingControl); + + CSettings& m_settings; + SettingCategoryList m_categories; + std::vector m_settingControls; + + int m_iCategory; int m_iSection; - int m_iScreen; - vecSettingsCategory m_vecSections; + CGUISpinControlEx *m_pOriginalSpin; CGUIRadioButtonControl *m_pOriginalRadioButton; CGUIButtonControl *m_pOriginalCategoryButton; CGUIButtonControl *m_pOriginalButton; CGUIEditControl *m_pOriginalEdit; CGUIImage *m_pOriginalImage; - - CStdString m_strErrorMessage; - - CStdString m_strOldTrackFormat; - CStdString m_strOldTrackFormatRight; - - std::map m_AnalogAudioSinkMap; - std::map m_DigitalAudioSinkMap; - std::map m_SkinFontSetIDs; + bool newOriginalEdit; + + BaseSettingControlPtr m_currentSetting; ///< Current setting control + BaseSettingControlPtr m_delayedSetting; ///< Current delayed setting \sa CBaseSettingControl::SetDelayed() + CTimer m_delayedTimer; ///< Delayed setting timer bool m_returningFromSkinLoad; // true if we are returning from loading the skin - - boost::shared_ptr m_delayedSetting; ///< Current delayed setting \sa CGUIBaseSettingControl::SetDelayed() - CStopWatch m_delayedTimer; ///< Delayed setting timer }; - diff --git a/xbmc/settings/windows/GUIWindowSettingsScreenCalibration.cpp b/xbmc/settings/windows/GUIWindowSettingsScreenCalibration.cpp index e286223feba02..0b4264dedf40f 100644 --- a/xbmc/settings/windows/GUIWindowSettingsScreenCalibration.cpp +++ b/xbmc/settings/windows/GUIWindowSettingsScreenCalibration.cpp @@ -28,7 +28,6 @@ #include "Application.h" #include "settings/DisplaySettings.h" #include "settings/Settings.h" -#include "settings/GUISettings.h" #include "guilib/GUIWindowManager.h" #include "dialogs/GUIDialogYesNo.h" #include "guilib/Key.h" @@ -119,7 +118,7 @@ bool CGUIWindowSettingsScreenCalibration::OnMessage(CGUIMessage& message) case GUI_MSG_WINDOW_DEINIT: { CDisplaySettings::Get().UpdateCalibrations(); - g_settings.Save(); + CSettings::Get().Save(); g_graphicsContext.SetCalibrating(false); g_windowManager.ShowOverlay(OVERLAY_STATE_SHOWN); // reset our screen resolution to what it was initially diff --git a/xbmc/settings/windows/Makefile b/xbmc/settings/windows/Makefile index 253a73b0b47f9..8f9761601ef72 100644 --- a/xbmc/settings/windows/Makefile +++ b/xbmc/settings/windows/Makefile @@ -1,4 +1,4 @@ -SRCS=GUISettingControls.cpp \ +SRCS=GUIControlSettings.cpp \ GUIWindowSettings.cpp \ GUIWindowSettingsCategory.cpp \ GUIWindowSettingsScreenCalibration.cpp \ diff --git a/xbmc/storage/MediaManager.cpp b/xbmc/storage/MediaManager.cpp index 3a2dcb4eaeed1..c89014d39d292 100644 --- a/xbmc/storage/MediaManager.cpp +++ b/xbmc/storage/MediaManager.cpp @@ -38,13 +38,13 @@ #include "Autorun.h" #include "GUIUserMessages.h" #include "settings/MediaSourceSettings.h" +#include "settings/Settings.h" #include "utils/XBMCTinyXML.h" #include "threads/SingleLock.h" #include "utils/log.h" #include "dialogs/GUIDialogKaiToast.h" #include "utils/JobManager.h" #include "AutorunMediaJob.h" -#include "settings/GUISettings.h" #include "FileItem.h" #include "filesystem/File.h" @@ -722,13 +722,15 @@ std::vector CMediaManager::GetDiskUsage() void CMediaManager::OnStorageAdded(const CStdString &label, const CStdString &path) { - if (g_guiSettings.GetInt("audiocds.autoaction") != AUTOCD_NONE || g_guiSettings.GetBool("dvds.autorun")) - if (g_guiSettings.GetInt("audiocds.autoaction") == AUTOCD_RIP) +#ifdef HAS_DVD_DRIVE + if (CSettings::Get().GetInt("audiocds.autoaction") != AUTOCD_NONE || CSettings::Get().GetBool("dvds.autorun")) + if (CSettings::Get().GetInt("audiocds.autoaction") == AUTOCD_RIP) CJobManager::GetInstance().AddJob(new CAutorunMediaJob(label, path), this, CJob::PRIORITY_LOW); else CJobManager::GetInstance().AddJob(new CAutorunMediaJob(label, path), this, CJob::PRIORITY_HIGH); else CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(13021), label, TOAST_DISPLAY_TIME, false); +#endif } void CMediaManager::OnStorageSafelyRemoved(const CStdString &label) diff --git a/xbmc/system.h b/xbmc/system.h index 8f099d314c541..40945686e9568 100644 --- a/xbmc/system.h +++ b/xbmc/system.h @@ -25,6 +25,9 @@ #define DECLARE_UNUSED(a,b) a __attribute__((unused)) b; #endif +#define PRE_SKIN_VERSION_9_10_COMPATIBILITY 1 +#define PRE_SKIN_VERSION_11_COMPATIBILITY 1 + /***************** * All platforms *****************/ @@ -269,3 +272,11 @@ #define GET_G(color) ((color >> 8) & 0xFF) #define GET_B(color) ((color >> 0) & 0xFF) +/**************** + * default skin + ****************/ +#if defined(HAS_SKIN_TOUCHED) && defined(TARGET_DARWIN_IOS) && !defined(TARGET_DARWIN_IOS_ATV2) +#define DEFAULT_SKIN "skin.touched" +#else +#define DEFAULT_SKIN "skin.confluence" +#endif diff --git a/xbmc/test/TestBasicEnvironment.cpp b/xbmc/test/TestBasicEnvironment.cpp index 521b912739d7c..80085b8fc133f 100644 --- a/xbmc/test/TestBasicEnvironment.cpp +++ b/xbmc/test/TestBasicEnvironment.cpp @@ -25,7 +25,7 @@ #include "filesystem/SpecialProtocol.h" #include "powermanagement/PowerManager.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "Util.h" #include @@ -59,7 +59,7 @@ void TestBasicEnvironment::SetUp() * that the initialization of these components won't be needed. */ g_powerManager.Initialize(); - g_guiSettings.Initialize(); + CSettings::Get().Initialize(); /* Create a temporary directory and set it to be used throughout the * test suite run. diff --git a/xbmc/utils/BooleanLogic.cpp b/xbmc/utils/BooleanLogic.cpp new file mode 100644 index 0000000000000..1a978c67417fa --- /dev/null +++ b/xbmc/utils/BooleanLogic.cpp @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2012 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 + * . + * + */ + +#include "BooleanLogic.h" +#include "utils/log.h" +#include "utils/StringUtils.h" +#include "utils/XBMCTinyXML.h" + +bool CBooleanLogicValue::Deserialize(const TiXmlNode *node) +{ + if (node == NULL) + return false; + + const TiXmlElement *elem = node->ToElement(); + if (elem == NULL) + return false; + + if (node->FirstChild() != NULL && node->FirstChild()->Type() == TiXmlNode::TINYXML_TEXT) + m_value = node->FirstChild()->ValueStr(); + + m_negated = false; + const char *strNegated = elem->Attribute("negated"); + if (strNegated != NULL) + { + if (StringUtils::EqualsNoCase(strNegated, "true")) + m_negated = true; + else if (!StringUtils::EqualsNoCase(strNegated, "false")) + { + CLog::Log(LOGDEBUG, "CBooleanLogicValue: invalid negated value \"%s\"", strNegated); + return false; + } + } + + return true; +} + +CBooleanLogicOperation::~CBooleanLogicOperation() +{ + m_operations.clear(); + m_values.clear(); +} + +bool CBooleanLogicOperation::Deserialize(const TiXmlNode *node) +{ + if (node == NULL) + return false; + + // check if this is a simple operation with a single value directly expressed + // in the parent tag + if (node->FirstChild() == NULL || node->FirstChild()->Type() == TiXmlNode::TINYXML_TEXT) + { + CBooleanLogicValuePtr value = CBooleanLogicValuePtr(newValue()); + if (value == NULL || !value->Deserialize(node)) + { + CLog::Log(LOGDEBUG, "CBooleanLogicOperation: failed to deserialize implicit boolean value definition"); + return false; + } + + m_values.push_back(value); + return true; + } + + const TiXmlNode *operationNode = node->FirstChild(); + while (operationNode != NULL) + { + std::string tag = operationNode->ValueStr(); + if (StringUtils::EqualsNoCase(tag, "and") || StringUtils::EqualsNoCase(tag, "or")) + { + CBooleanLogicOperationPtr operation = CBooleanLogicOperationPtr(newOperation()); + if (operation == NULL) + return false; + + operation->SetOperation(StringUtils::EqualsNoCase(tag, "and") ? BooleanLogicOperationAnd : BooleanLogicOperationOr); + if (!operation->Deserialize(operationNode)) + { + CLog::Log(LOGDEBUG, "CBooleanLogicOperation: failed to deserialize <%s> definition", tag.c_str()); + return false; + } + + m_operations.push_back(operation); + } + else + { + CBooleanLogicValuePtr value = CBooleanLogicValuePtr(newValue()); + if (value == NULL) + return false; + + if (StringUtils::EqualsNoCase(tag, value->GetTag())) + { + if (!value->Deserialize(operationNode)) + { + CLog::Log(LOGDEBUG, "CBooleanLogicOperation: failed to deserialize <%s> definition", tag.c_str()); + return false; + } + + m_values.push_back(value); + } + else if (operationNode->Type() == TiXmlNode::TINYXML_ELEMENT) + CLog::Log(LOGDEBUG, "CBooleanLogicOperation: unknown <%s> definition encountered", tag.c_str()); + } + + operationNode = operationNode->NextSibling(); + } + + return true; +} + +bool CBooleanLogic::Deserialize(const TiXmlNode *node) +{ + if (node == NULL) + return false; + + if (m_operation == NULL) + { + m_operation = CBooleanLogicOperationPtr(new CBooleanLogicOperation()); + + if (m_operation == NULL) + return false; + } + + return m_operation->Deserialize(node); +} diff --git a/xbmc/utils/BooleanLogic.h b/xbmc/utils/BooleanLogic.h new file mode 100644 index 0000000000000..b44de38795e01 --- /dev/null +++ b/xbmc/utils/BooleanLogic.h @@ -0,0 +1,101 @@ +#pragma once +/* + * Copyright (C) 2012 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 + * . + * + */ + +#include +#include + +#include + +#include "utils/IXmlDeserializable.h" + +typedef enum { + BooleanLogicOperationOr = 0, + BooleanLogicOperationAnd +} BooleanLogicOperation; + +class CBooleanLogicValue : public IXmlDeserializable +{ +public: + CBooleanLogicValue(const std::string &value = "", bool negated = false) + : m_value(value), m_negated(negated) + { } + virtual ~CBooleanLogicValue() { } + + virtual bool Deserialize(const TiXmlNode *node); + + virtual const std::string& GetValue() const { return m_value; } + virtual bool IsNegated() const { return m_negated; } + virtual const char* GetTag() const { return "value"; } + + virtual void SetValue(const std::string &value) { m_value = value; } + virtual void SetNegated(bool negated) { m_negated = negated; } + +protected: + std::string m_value; + bool m_negated; +}; + +typedef boost::shared_ptr CBooleanLogicValuePtr; +typedef std::vector CBooleanLogicValues; + +class CBooleanLogicOperation; +typedef boost::shared_ptr CBooleanLogicOperationPtr; +typedef std::vector CBooleanLogicOperations; + +class CBooleanLogicOperation : public IXmlDeserializable +{ +public: + CBooleanLogicOperation(BooleanLogicOperation op = BooleanLogicOperationAnd) + : m_operation(op) + { } + virtual ~CBooleanLogicOperation(); + + virtual bool Deserialize(const TiXmlNode *node); + + virtual BooleanLogicOperation GetOperation() const { return m_operation; } + virtual const CBooleanLogicOperations& GetOperations() const { return m_operations; } + virtual const CBooleanLogicValues& GetValues() const { return m_values; } + + virtual void SetOperation(BooleanLogicOperation op) { m_operation = op; } + +protected: + virtual CBooleanLogicOperation* newOperation() { return new CBooleanLogicOperation(); } + virtual CBooleanLogicValue* newValue() { return new CBooleanLogicValue(); } + + BooleanLogicOperation m_operation; + CBooleanLogicOperations m_operations; + CBooleanLogicValues m_values; +}; + +class CBooleanLogic : public IXmlDeserializable +{ +public: + CBooleanLogic() { } + virtual ~CBooleanLogic() { } + + virtual bool Deserialize(const TiXmlNode *node); + + virtual const CBooleanLogicOperationPtr& Get() const { return m_operation; } + virtual CBooleanLogicOperationPtr Get() { return m_operation; } + +protected: + CBooleanLogicOperationPtr m_operation; +}; diff --git a/xbmc/utils/CharsetConverter.cpp b/xbmc/utils/CharsetConverter.cpp index 4e37b7d452a5b..f5001fff49350 100644 --- a/xbmc/utils/CharsetConverter.cpp +++ b/xbmc/utils/CharsetConverter.cpp @@ -22,6 +22,8 @@ #include "Util.h" #include #include "LangInfo.h" +#include "guilib/LocalizeStrings.h" +#include "settings/Setting.h" #include "threads/SingleLock.h" #include "log.h" @@ -339,6 +341,19 @@ CCharsetConverter::CCharsetConverter() { } +void CCharsetConverter::OnSettingChanged(const CSetting *setting) +{ + if (setting == NULL) + return; + + const std::string &settingId = setting->GetId(); + // TODO: does this make any sense at all for subtitles and karaoke? + if (settingId == "subtitles.charset" || + settingId == "karaoke.charset" || + settingId == "locale.charset") + reset(); +} + void CCharsetConverter::clear() { } @@ -700,3 +715,13 @@ void CCharsetConverter::utf8logicalToVisualBiDi(const CStdStringA& strSource, CS { logicalToVisualBiDi(strSource, strDest, FRIBIDI_UTF8, FRIBIDI_TYPE_RTL); } + +void CCharsetConverter::SettingOptionsCharsetsFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t) +{ + vector vecCharsets = g_charsetConverter.getCharsetLabels(); + sort(vecCharsets.begin(), vecCharsets.end(), sortstringbyname()); + + list.push_back(make_pair(g_localizeStrings.Get(13278), "DEFAULT")); // "Default" + for (int i = 0; i < (int) vecCharsets.size(); ++i) + list.push_back(make_pair(vecCharsets[i], g_charsetConverter.getCharsetNameByLabel(vecCharsets[i]))); +} diff --git a/xbmc/utils/CharsetConverter.h b/xbmc/utils/CharsetConverter.h index 62780aa2b1c03..36602961dbcf1 100644 --- a/xbmc/utils/CharsetConverter.h +++ b/xbmc/utils/CharsetConverter.h @@ -21,17 +21,22 @@ * */ +#include "settings/ISettingCallback.h" #include "threads/CriticalSection.h" -#include "StdString.h" #include "utils/GlobalsHandling.h" +#include "utils/StdString.h" #include -class CCharsetConverter +class CSetting; + +class CCharsetConverter : public ISettingCallback { public: CCharsetConverter(); + virtual void OnSettingChanged(const CSetting *setting); + void reset(); void clear(); @@ -78,6 +83,8 @@ class CCharsetConverter void toW(const CStdStringA& source, CStdStringW& dest, const CStdStringA& enc); void fromW(const CStdStringW& source, CStdStringA& dest, const CStdStringA& enc); + + static void SettingOptionsCharsetsFiller(const CSetting *setting, std::vector< std::pair > &list, std::string ¤t); }; XBMC_GLOBAL(CCharsetConverter,g_charsetConverter); diff --git a/xbmc/utils/EdenVideoArtUpdater.cpp b/xbmc/utils/EdenVideoArtUpdater.cpp index 71b8f017a5448..fd55f4f4e778c 100644 --- a/xbmc/utils/EdenVideoArtUpdater.cpp +++ b/xbmc/utils/EdenVideoArtUpdater.cpp @@ -31,8 +31,8 @@ #include "TextureCacheJob.h" #include "pictures/Picture.h" #include "profiles/ProfilesManager.h" -#include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" +#include "settings/Settings.h" #include "guilib/Texture.h" #include "guilib/GUIWindowManager.h" #include "guilib/LocalizeStrings.h" @@ -246,7 +246,7 @@ void CEdenVideoArtUpdater::Process() items.Clear(); // now actors - if (g_guiSettings.GetBool("videolibrary.actorthumbs")) + if (CSettings::Get().GetBool("videolibrary.actorthumbs")) { db.GetActorsNav("videodb://movies/titles/", items, VIDEODB_CONTENT_MOVIES); db.GetActorsNav("videodb://tvshows/titles/", items, VIDEODB_CONTENT_TVSHOWS); diff --git a/xbmc/utils/IXmlDeserializable.h b/xbmc/utils/IXmlDeserializable.h new file mode 100644 index 0000000000000..a7d3a27a52daf --- /dev/null +++ b/xbmc/utils/IXmlDeserializable.h @@ -0,0 +1,30 @@ +#pragma once +/* + * Copyright (C) 2012 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 + * . + * + */ + +class TiXmlNode; + +class IXmlDeserializable +{ +public: + virtual ~IXmlDeserializable() { } + + virtual bool Deserialize(const TiXmlNode *node) = 0; +}; diff --git a/xbmc/utils/LabelFormatter.cpp b/xbmc/utils/LabelFormatter.cpp index 957f56f2a5e4c..906033622c852 100644 --- a/xbmc/utils/LabelFormatter.cpp +++ b/xbmc/utils/LabelFormatter.cpp @@ -19,8 +19,8 @@ */ #include "LabelFormatter.h" -#include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" +#include "settings/Settings.h" #include "RegExp.h" #include "Util.h" #include "video/VideoInfoTag.h" @@ -108,7 +108,7 @@ CLabelFormatter::CLabelFormatter(const CStdString &mask, const CStdString &mask2 AssembleMask(0, mask); AssembleMask(1, mask2); // save a bool for faster lookups - m_hideFileExtensions = !g_guiSettings.GetBool("filelists.showextensions"); + m_hideFileExtensions = !CSettings::Get().GetBool("filelists.showextensions"); } CStdString CLabelFormatter::GetContent(unsigned int label, const CFileItem *item) const diff --git a/xbmc/utils/Makefile b/xbmc/utils/Makefile index 57c67ef385332..c4026cf794cec 100644 --- a/xbmc/utils/Makefile +++ b/xbmc/utils/Makefile @@ -6,6 +6,7 @@ SRCS=AlarmClock.cpp \ Base64.cpp \ BitstreamConverter.cpp \ BitstreamStats.cpp \ + BooleanLogic.cpp \ CharsetConverter.cpp \ CPUInfo.cpp \ Crc32.cpp \ diff --git a/xbmc/utils/Observer.h b/xbmc/utils/Observer.h index 5ebd23cd32f96..a54017fac8b8a 100644 --- a/xbmc/utils/Observer.h +++ b/xbmc/utils/Observer.h @@ -29,7 +29,6 @@ typedef enum { ObservableMessageNone, ObservableMessageCurrentItem, - ObservableMessageGuiSettings, ObservableMessageAddons, ObservableMessageEpg, ObservableMessageEpgContainer, diff --git a/xbmc/utils/RssManager.cpp b/xbmc/utils/RssManager.cpp index 686c3eb2269a2..8b71ed527183b 100644 --- a/xbmc/utils/RssManager.cpp +++ b/xbmc/utils/RssManager.cpp @@ -19,8 +19,13 @@ */ #include "RssManager.h" +#include "addons/AddonInstaller.h" +#include "addons/AddonManager.h" +#include "dialogs/GUIDialogYesNo.h" #include "filesystem/File.h" +#include "interfaces/Builtins.h" #include "profiles/ProfilesManager.h" +#include "settings/Setting.h" #include "threads/SingleLock.h" #include "utils/log.h" #include "utils/RssReader.h" @@ -55,6 +60,26 @@ void CRssManager::OnSettingsCleared() Clear(); } +void CRssManager::OnSettingAction(const CSetting *setting) +{ + if (setting == NULL) + return; + + const std::string &settingId = setting->GetId(); + if (settingId == "lookandfeel.rssedit") + { + ADDON::AddonPtr addon; + ADDON::CAddonMgr::Get().GetAddon("script.rss.editor",addon); + if (!addon) + { + if (!CGUIDialogYesNo::ShowAndGetInput(g_localizeStrings.Get(24076), g_localizeStrings.Get(24100), "RSS Editor", g_localizeStrings.Get(24101))) + return; + CAddonInstaller::Get().Install("script.rss.editor", true, "", false); + } + CBuiltins::Execute("RunScript(script.rss.editor)"); + } +} + void CRssManager::Start() { m_bActive = true; diff --git a/xbmc/utils/RssManager.h b/xbmc/utils/RssManager.h index 5277876c67a13..8fd187d7098d7 100644 --- a/xbmc/utils/RssManager.h +++ b/xbmc/utils/RssManager.h @@ -25,6 +25,7 @@ #include "threads/CriticalSection.h" +#include "settings/ISettingCallback.h" #include "settings/ISettingsHandler.h" class CRssReader; @@ -38,7 +39,7 @@ typedef struct } RssSet; typedef std::map RssUrls; -class CRssManager : public ISettingsHandler +class CRssManager : public ISettingCallback, public ISettingsHandler { public: static CRssManager& Get(); @@ -46,6 +47,8 @@ class CRssManager : public ISettingsHandler virtual void OnSettingsLoaded(); virtual void OnSettingsCleared(); + virtual void OnSettingAction(const CSetting *setting); + void Start(); void Stop(); bool Load(); diff --git a/xbmc/utils/Screenshot.cpp b/xbmc/utils/Screenshot.cpp index 0f5039905d096..d86a240e93611 100644 --- a/xbmc/utils/Screenshot.cpp +++ b/xbmc/utils/Screenshot.cpp @@ -39,7 +39,9 @@ #include "utils/JobManager.h" #include "utils/URIUtils.h" #include "utils/log.h" -#include "settings/GUISettings.h" +#include "settings/SettingPath.h" +#include "settings/Settings.h" +#include "settings/windows/GUIControlSettings.h" using namespace std; using namespace XFILE; @@ -204,10 +206,21 @@ void CScreenShot::TakeScreenshot() { static bool savingScreenshots = false; static vector screenShots; - bool promptUser = false; + CStdString strDir; + // check to see if we have a screenshot folder yet - CStdString strDir = g_guiSettings.GetString("debug.screenshotpath", false); + CSettingPath *screenshotSetting = (CSettingPath*)CSettings::Get().GetSetting("debug.screenshotpath"); + if (screenshotSetting != NULL) + { + strDir = screenshotSetting->GetValue(); + if (strDir.empty()) + { + if (CGUIControlButtonSetting::GetPath(screenshotSetting)) + strDir = screenshotSetting->GetValue(); + } + } + if (strDir.IsEmpty()) { strDir = "special://temp/"; @@ -231,7 +244,17 @@ void CScreenShot::TakeScreenshot() screenShots.push_back(file); if (promptUser) { // grab the real directory - CStdString newDir = g_guiSettings.GetString("debug.screenshotpath"); + CStdString newDir; + if (screenshotSetting != NULL) + { + newDir = screenshotSetting->GetValue(); + if (newDir.empty()) + { + if (CGUIControlButtonSetting::GetPath(screenshotSetting)) + newDir = screenshotSetting->GetValue(); + } + } + if (!newDir.IsEmpty()) { for (unsigned int i = 0; i < screenShots.size(); i++) diff --git a/xbmc/utils/URIUtils.cpp b/xbmc/utils/URIUtils.cpp index 3392fe968933a..6245cd40d0e8a 100644 --- a/xbmc/utils/URIUtils.cpp +++ b/xbmc/utils/URIUtils.cpp @@ -28,6 +28,7 @@ #include "filesystem/StackDirectory.h" #include "network/DNSNameCache.h" #include "settings/AdvancedSettings.h" +#include "settings/MediaSettings.h" #include "URL.h" #include "StringUtils.h" diff --git a/xbmc/utils/Weather.cpp b/xbmc/utils/Weather.cpp index 19d0039217ece..a0c882d4ff584 100644 --- a/xbmc/utils/Weather.cpp +++ b/xbmc/utils/Weather.cpp @@ -28,7 +28,6 @@ #include "Temperature.h" #include "network/Network.h" #include "Application.h" -#include "settings/GUISettings.h" #include "settings/Settings.h" #include "guilib/GUIWindowManager.h" #include "GUIUserMessages.h" @@ -43,6 +42,7 @@ #include "addons/AddonManager.h" #include "interfaces/python/XBPython.h" #include "CharsetConverter.h" +#include "addons/GUIDialogAddonSettings.h" using namespace std; using namespace ADDON; @@ -80,7 +80,7 @@ bool CWeatherJob::DoWork() return false; AddonPtr addon; - if (!ADDON::CAddonMgr::Get().GetAddon(g_guiSettings.GetString("weather.addon"), addon, ADDON_SCRIPT_WEATHER)) + if (!ADDON::CAddonMgr::Get().GetAddon(CSettings::Get().GetString("weather.addon"), addon, ADDON_SCRIPT_WEATHER)) return false; // initialize our sys.argv variables @@ -458,8 +458,8 @@ const day_forecast &CWeather::GetForecast(int day) const */ void CWeather::SetArea(int iLocation) { - g_guiSettings.SetInt("weather.currentlocation", iLocation); - g_settings.Save(); + CSettings::Get().SetInt("weather.currentlocation", iLocation); + CSettings::Get().Save(); } /*! @@ -468,7 +468,7 @@ void CWeather::SetArea(int iLocation) */ int CWeather::GetArea() const { - return g_guiSettings.GetInt("weather.currentlocation"); + return CSettings::Get().GetInt("weather.currentlocation"); } CJob *CWeather::GetJob() const @@ -481,3 +481,31 @@ void CWeather::OnJobComplete(unsigned int jobID, bool success, CJob *job) m_info = ((CWeatherJob *)job)->GetInfo(); CInfoLoader::OnJobComplete(jobID, success, job); } + +void CWeather::OnSettingChanged(const CSetting *setting) +{ + if (setting == NULL) + return; + + const std::string settingId = setting->GetId(); + if (settingId == "weather.addon") + Refresh(); +} + +void CWeather::OnSettingAction(const CSetting *setting) +{ + if (setting == NULL) + return; + + const std::string settingId = setting->GetId(); + if (settingId == "weather.addonsettings") + { + AddonPtr addon; + if (CAddonMgr::Get().GetAddon(CSettings::Get().GetString("weather.addon"), addon, ADDON_SCRIPT_WEATHER) && addon != NULL) + { // TODO: maybe have ShowAndGetInput return a bool if settings changed, then only reset weather if true. + CGUIDialogAddonSettings::ShowAndGetInput(addon); + Refresh(); + } + } +} + diff --git a/xbmc/utils/Weather.h b/xbmc/utils/Weather.h index 43b0472026f81..4043e8b082e5d 100644 --- a/xbmc/utils/Weather.h +++ b/xbmc/utils/Weather.h @@ -22,6 +22,7 @@ #include "InfoLoader.h" #include "StdString.h" +#include "settings/ISettingCallback.h" #include "utils/GlobalsHandling.h" #include @@ -138,7 +139,8 @@ class CWeatherJob : public CJob static bool m_imagesOkay; }; -class CWeather : public CInfoLoader +class CWeather : public CInfoLoader, + public ISettingCallback { public: CWeather(void); @@ -159,6 +161,9 @@ class CWeather : public CInfoLoader virtual CStdString BusyInfo(int info) const; virtual void OnJobComplete(unsigned int jobID, bool success, CJob *job); + virtual void OnSettingChanged(const CSetting *setting); + virtual void OnSettingAction(const CSetting *setting); + private: CWeatherInfo m_info; diff --git a/xbmc/utils/XBMCTinyXML.h b/xbmc/utils/XBMCTinyXML.h index 88726b4a0b124..cf8c18a34d161 100644 --- a/xbmc/utils/XBMCTinyXML.h +++ b/xbmc/utils/XBMCTinyXML.h @@ -54,7 +54,7 @@ #undef ELEMENT #undef COMMENT #undef UNKNOWN -#undef TEXT +//#undef TEXT #undef DECLARATION #undef TYPECOUNT diff --git a/xbmc/utils/log.cpp b/xbmc/utils/log.cpp index da6de6dd9450b..bdb24766f04dc 100644 --- a/xbmc/utils/log.cpp +++ b/xbmc/utils/log.cpp @@ -139,8 +139,8 @@ bool CLog::Init(const char* path) CSingleLock waitLock(critSec); if (!m_file) { - // g_advancedSettings.m_logFolder is initialized in the CSettings constructor - // and changed in CApplication::Create() + // the log folder location is initialized in the CAdvancedSettings + // constructor and changed in CApplication::Create() CStdString strLogFile, strLogFileOld; strLogFile.Format("%sxbmc.log", path); diff --git a/xbmc/utils/test/TestCharsetConverter.cpp b/xbmc/utils/test/TestCharsetConverter.cpp index 5c21ad609addf..134315fb71040 100644 --- a/xbmc/utils/test/TestCharsetConverter.cpp +++ b/xbmc/utils/test/TestCharsetConverter.cpp @@ -18,7 +18,7 @@ * */ -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/CharsetConverter.h" #include "gtest/gtest.h" @@ -83,19 +83,21 @@ class TestCharsetConverter : public testing::Test /* Add default settings for locale. * Settings here are taken from CGUISettings::Initialize() */ - CSettingsCategory *loc = g_guiSettings.AddCategory(7, "locale", 14090); - g_guiSettings.AddString(loc, "locale.language",248,"english", + /* TODO + CSettingsCategory *loc = CSettings::Get().AddCategory(7, "locale", 14090); + CSettings::Get().AddString(loc, "locale.language",248,"english", SPIN_CONTROL_TEXT); - g_guiSettings.AddString(loc, "locale.country", 20026, "USA", + CSettings::Get().AddString(loc, "locale.country", 20026, "USA", SPIN_CONTROL_TEXT); - g_guiSettings.AddString(loc, "locale.charset", 14091, "DEFAULT", + CSettings::Get().AddString(loc, "locale.charset", 14091, "DEFAULT", SPIN_CONTROL_TEXT); // charset is set by the // language file - /* Add default settings for subtitles */ - CSettingsCategory *sub = g_guiSettings.AddCategory(5, "subtitles", 287); - g_guiSettings.AddString(sub, "subtitles.charset", 735, "DEFAULT", + // Add default settings for subtitles + CSettingsCategory *sub = CSettings::Get().AddCategory(5, "subtitles", 287); + CSettings::Get().AddString(sub, "subtitles.charset", 735, "DEFAULT", SPIN_CONTROL_TEXT); + */ g_charsetConverter.reset(); g_charsetConverter.clear(); @@ -103,7 +105,7 @@ class TestCharsetConverter : public testing::Test ~TestCharsetConverter() { - g_guiSettings.Clear(); + CSettings::Get().Unload(); } CStdStringA refstra1, refstra2, varstra1; diff --git a/xbmc/utils/test/TestDownloadQueue.cpp b/xbmc/utils/test/TestDownloadQueue.cpp index 69387286b2e29..220448f588b5c 100644 --- a/xbmc/utils/test/TestDownloadQueue.cpp +++ b/xbmc/utils/test/TestDownloadQueue.cpp @@ -20,7 +20,7 @@ #include "utils/DownloadQueue.h" #include "threads/Thread.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "test/TestUtils.h" #include "gtest/gtest.h" @@ -40,23 +40,23 @@ class TestDownloadQueue : public testing::Test protected: TestDownloadQueue() { - CSettingsCategory* net = g_guiSettings.AddCategory(4, "network", 798); - g_guiSettings.AddBool(net, "network.usehttpproxy", 708, false); - g_guiSettings.AddString(net, "network.httpproxyserver", 706, "", + CSettingsCategory* net = CSettings::Get().AddCategory(4, "network", 798); + CSettings::Get().AddBool(net, "network.usehttpproxy", 708, false); + CSettings::Get().AddString(net, "network.httpproxyserver", 706, "", EDIT_CONTROL_INPUT); - g_guiSettings.AddString(net, "network.httpproxyport", 730, "8080", + CSettings::Get().AddString(net, "network.httpproxyport", 730, "8080", EDIT_CONTROL_NUMBER_INPUT, false, 707); - g_guiSettings.AddString(net, "network.httpproxyusername", 1048, "", + CSettings::Get().AddString(net, "network.httpproxyusername", 1048, "", EDIT_CONTROL_INPUT); - g_guiSettings.AddString(net, "network.httpproxypassword", 733, "", + CSettings::Get().AddString(net, "network.httpproxypassword", 733, "", EDIT_CONTROL_HIDDEN_INPUT,true,733); - g_guiSettings.AddInt(net, "network.bandwidth", 14041, 0, 0, 512, 100*1024, + CSettings::Get().AddInt(net, "network.bandwidth", 14041, 0, 0, 512, 100*1024, SPIN_CONTROL_INT_PLUS, 14048, 351); } ~TestDownloadQueue() { - g_guiSettings.Clear(); + CSettings::Get().Clear(); } }; diff --git a/xbmc/utils/test/TestDownloadQueueManager.cpp b/xbmc/utils/test/TestDownloadQueueManager.cpp index c137c5bfc2e9b..aa8c2e024f9a1 100644 --- a/xbmc/utils/test/TestDownloadQueueManager.cpp +++ b/xbmc/utils/test/TestDownloadQueueManager.cpp @@ -20,7 +20,7 @@ #include "utils/DownloadQueueManager.h" #include "threads/Thread.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "test/TestUtils.h" #include "gtest/gtest.h" @@ -40,23 +40,25 @@ class TestDownloadQueueManager : public testing::Test protected: TestDownloadQueueManager() { - CSettingsCategory* net = g_guiSettings.AddCategory(4, "network", 798); - g_guiSettings.AddBool(net, "network.usehttpproxy", 708, false); - g_guiSettings.AddString(net, "network.httpproxyserver", 706, "", + /* TODO + CSettingsCategory* net = CSettings::Get().AddCategory(4, "network", 798); + CSettings::Get().AddBool(net, "network.usehttpproxy", 708, false); + CSettings::Get().AddString(net, "network.httpproxyserver", 706, "", EDIT_CONTROL_INPUT); - g_guiSettings.AddString(net, "network.httpproxyport", 730, "8080", + CSettings::Get().AddString(net, "network.httpproxyport", 730, "8080", EDIT_CONTROL_NUMBER_INPUT, false, 707); - g_guiSettings.AddString(net, "network.httpproxyusername", 1048, "", + CSettings::Get().AddString(net, "network.httpproxyusername", 1048, "", EDIT_CONTROL_INPUT); - g_guiSettings.AddString(net, "network.httpproxypassword", 733, "", + CSettings::Get().AddString(net, "network.httpproxypassword", 733, "", EDIT_CONTROL_HIDDEN_INPUT,true,733); - g_guiSettings.AddInt(net, "network.bandwidth", 14041, 0, 0, 512, 100*1024, + CSettings::Get().AddInt(net, "network.bandwidth", 14041, 0, 0, 512, 100*1024, SPIN_CONTROL_INT_PLUS, 14048, 351); + */ } ~TestDownloadQueueManager() { - g_guiSettings.Clear(); + CSettings::Get().Unload(); } }; diff --git a/xbmc/utils/test/TestJobManager.cpp b/xbmc/utils/test/TestJobManager.cpp index bf77c97175b05..197ad3077d0f7 100644 --- a/xbmc/utils/test/TestJobManager.cpp +++ b/xbmc/utils/test/TestJobManager.cpp @@ -19,7 +19,7 @@ */ #include "utils/JobManager.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/SystemInfo.h" #include "gtest/gtest.h" @@ -30,23 +30,25 @@ class TestJobManager : public testing::Test protected: TestJobManager() { - CSettingsCategory* net = g_guiSettings.AddCategory(4, "network", 798); - g_guiSettings.AddBool(net, "network.usehttpproxy", 708, false); - g_guiSettings.AddString(net, "network.httpproxyserver", 706, "", + /* TODO + CSettingsCategory* net = CSettings::Get().AddCategory(4, "network", 798); + CSettings::Get().AddBool(net, "network.usehttpproxy", 708, false); + CSettings::Get().AddString(net, "network.httpproxyserver", 706, "", EDIT_CONTROL_INPUT); - g_guiSettings.AddString(net, "network.httpproxyport", 730, "8080", + CSettings::Get().AddString(net, "network.httpproxyport", 730, "8080", EDIT_CONTROL_NUMBER_INPUT, false, 707); - g_guiSettings.AddString(net, "network.httpproxyusername", 1048, "", + CSettings::Get().AddString(net, "network.httpproxyusername", 1048, "", EDIT_CONTROL_INPUT); - g_guiSettings.AddString(net, "network.httpproxypassword", 733, "", + CSettings::Get().AddString(net, "network.httpproxypassword", 733, "", EDIT_CONTROL_HIDDEN_INPUT,true,733); - g_guiSettings.AddInt(net, "network.bandwidth", 14041, 0, 0, 512, 100*1024, + CSettings::Get().AddInt(net, "network.bandwidth", 14041, 0, 0, 512, 100*1024, SPIN_CONTROL_INT_PLUS, 14048, 351); + */ } ~TestJobManager() { - g_guiSettings.Clear(); + CSettings::Get().Unload(); } }; diff --git a/xbmc/utils/test/TestLabelFormatter.cpp b/xbmc/utils/test/TestLabelFormatter.cpp index e0e67b88c5206..b21c2b9465bdd 100644 --- a/xbmc/utils/test/TestLabelFormatter.cpp +++ b/xbmc/utils/test/TestLabelFormatter.cpp @@ -20,7 +20,7 @@ #include "utils/LabelFormatter.h" #include "filesystem/File.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "FileItem.h" #include "test/TestUtils.h" @@ -33,18 +33,20 @@ class TestLabelFormatter : public testing::Test protected: TestLabelFormatter() { - CSettingsCategory* fl = g_guiSettings.AddCategory(7, "filelists", 14081); - g_guiSettings.AddBool(fl, "filelists.showparentdiritems", 13306, true); - g_guiSettings.AddBool(fl, "filelists.showextensions", 497, true); - g_guiSettings.AddBool(fl, "filelists.ignorethewhensorting", 13399, true); - g_guiSettings.AddBool(fl, "filelists.allowfiledeletion", 14071, false); - g_guiSettings.AddBool(fl, "filelists.showaddsourcebuttons", 21382, true); - g_guiSettings.AddBool(fl, "filelists.showhidden", 21330, false); + /* TODO + CSettingsCategory* fl = CSettings::Get().AddCategory(7, "filelists", 14081); + CSettings::Get().AddBool(fl, "filelists.showparentdiritems", 13306, true); + CSettings::Get().AddBool(fl, "filelists.showextensions", 497, true); + CSettings::Get().AddBool(fl, "filelists.ignorethewhensorting", 13399, true); + CSettings::Get().AddBool(fl, "filelists.allowfiledeletion", 14071, false); + CSettings::Get().AddBool(fl, "filelists.showaddsourcebuttons", 21382, true); + CSettings::Get().AddBool(fl, "filelists.showhidden", 21330, false); + */ } ~TestLabelFormatter() { - g_guiSettings.Clear(); + CSettings::Get().Unload(); } }; diff --git a/xbmc/utils/test/TestSystemInfo.cpp b/xbmc/utils/test/TestSystemInfo.cpp index 628539b60927a..c8a92fb9cf976 100644 --- a/xbmc/utils/test/TestSystemInfo.cpp +++ b/xbmc/utils/test/TestSystemInfo.cpp @@ -19,7 +19,7 @@ */ #include "utils/SystemInfo.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "GUIInfoManager.h" #include "gtest/gtest.h" @@ -29,22 +29,22 @@ class TestSystemInfo : public testing::Test protected: TestSystemInfo() { - CSettingsCategory* net = g_guiSettings.AddCategory(4, "network", 798); - g_guiSettings.AddBool(net, "network.usehttpproxy", 708, false); - g_guiSettings.AddString(net, "network.httpproxyserver", 706, "", + CSettingsCategory* net = CSettings::Get().AddCategory(4, "network", 798); + CSettings::Get().AddBool(net, "network.usehttpproxy", 708, false); + CSettings::Get().AddString(net, "network.httpproxyserver", 706, "", EDIT_CONTROL_INPUT); - g_guiSettings.AddString(net, "network.httpproxyport", 730, "8080", + CSettings::Get().AddString(net, "network.httpproxyport", 730, "8080", EDIT_CONTROL_NUMBER_INPUT, false, 707); - g_guiSettings.AddString(net, "network.httpproxyusername", 1048, "", + CSettings::Get().AddString(net, "network.httpproxyusername", 1048, "", EDIT_CONTROL_INPUT); - g_guiSettings.AddString(net, "network.httpproxypassword", 733, "", + CSettings::Get().AddString(net, "network.httpproxypassword", 733, "", EDIT_CONTROL_HIDDEN_INPUT,true,733); - g_guiSettings.AddInt(net, "network.bandwidth", 14041, 0, 0, 512, 100*1024, + CSettings::Get().AddInt(net, "network.bandwidth", 14041, 0, 0, 512, 100*1024, SPIN_CONTROL_INT_PLUS, 14048, 351); } ~TestSystemInfo() { - g_guiSettings.Clear(); + CSettings::Get().Clear(); } }; diff --git a/xbmc/utils/test/TestURIUtils.cpp b/xbmc/utils/test/TestURIUtils.cpp index 548af2750319c..ed43e3a3b7d11 100644 --- a/xbmc/utils/test/TestURIUtils.cpp +++ b/xbmc/utils/test/TestURIUtils.cpp @@ -85,7 +85,7 @@ TEST_F(TestURIUtils, RemoveExtension) { CStdString ref, var; - /* NOTE: g_settings need to be set to find other extensions. */ + /* NOTE: CSettings need to be set to find other extensions. */ ref = "/path/to/file"; var = "/path/to/file.xml"; URIUtils::RemoveExtension(var); diff --git a/xbmc/video/GUIViewStateVideo.cpp b/xbmc/video/GUIViewStateVideo.cpp index 5185bda285f6f..4c0df1ff2458a 100644 --- a/xbmc/video/GUIViewStateVideo.cpp +++ b/xbmc/video/GUIViewStateVideo.cpp @@ -25,10 +25,10 @@ #include "filesystem/VideoDatabaseDirectory.h" #include "filesystem/Directory.h" #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" @@ -72,15 +72,15 @@ CGUIViewStateWindowVideoFiles::CGUIViewStateWindowVideoFiles(const CFileItemList } else { - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%L", "%I", "%L", "")); // Label, Size | Label, empty else AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%L", "%I", "%L", "")); // Label, Size | Label, empty 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 - - CViewState *viewState = CViewStateSettings::Get().Get("videofiles"); + + const CViewState *viewState = CViewStateSettings::Get().Get("videofiles"); SetSortMethod(viewState->m_sortMethod); SetViewAsControl(viewState->m_viewMode); SetSortOrder(viewState->m_sortOrder); @@ -138,8 +138,8 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it { AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", "%R", "%L", "")); // Title, Rating | Label, empty SetSortMethod(SORT_METHOD_LABEL); - - CViewState *viewState = CViewStateSettings::Get().Get("videonavactors"); + + const CViewState *viewState = CViewStateSettings::Get().Get("videonavactors"); SetViewAsControl(viewState->m_viewMode); SetSortOrder(viewState->m_sortOrder); } @@ -148,8 +148,8 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it { AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", "%R", "%L", "")); // Title, Rating | Label, empty SetSortMethod(SORT_METHOD_LABEL); - - CViewState *viewState = CViewStateSettings::Get().Get("videonavyears"); + + const CViewState *viewState = CViewStateSettings::Get().Get("videonavyears"); SetViewAsControl(viewState->m_viewMode); SetSortOrder(viewState->m_sortOrder); } @@ -158,15 +158,15 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it { AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556, LABEL_MASKS("%L", "","%L","")); // Label, empty | Label, empty SetSortMethod(SORT_METHOD_VIDEO_SORT_TITLE); - - CViewState *viewState = CViewStateSettings::Get().Get("videonavseasons"); + + const CViewState *viewState = CViewStateSettings::Get().Get("videonavseasons"); SetViewAsControl(viewState->m_viewMode); SetSortOrder(viewState->m_sortOrder); } break; case NODE_TYPE_TITLE_TVSHOWS: { - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes else AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556, LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes @@ -176,8 +176,8 @@ 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); - - CViewState *viewState = CViewStateSettings::Get().Get("videonavtvshows"); + + const CViewState *viewState = CViewStateSettings::Get().Get("videonavtvshows"); SetViewAsControl(viewState->m_viewMode); SetSortOrder(viewState->m_sortOrder); } @@ -189,15 +189,15 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it { AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", "%R", "%L", "")); // Title, Rating | Label, empty SetSortMethod(SORT_METHOD_LABEL); - - CViewState *viewState = CViewStateSettings::Get().Get("videonavgenres"); + + const CViewState *viewState = CViewStateSettings::Get().Get("videonavgenres"); SetViewAsControl(viewState->m_viewMode); SetSortOrder(viewState->m_sortOrder); } break; case NODE_TYPE_SETS: { - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%T","%R", "%T","%R")); // Title, Rating | Title, Rating else AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", "%R", "%T","%R")); // Title, Rating | Title, Rating @@ -210,8 +210,8 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it AddSortMethod(SORT_METHOD_PLAYCOUNT, 567, LABEL_MASKS("%T", "%V", "%T", "%V")); // Title, Playcount | Title, Playcount SetSortMethod(SORT_METHOD_LABEL_IGNORE_THE); - - CViewState *viewState = CViewStateSettings::Get().Get("videonavgenres"); + + const CViewState *viewState = CViewStateSettings::Get().Get("videonavgenres"); SetViewAsControl(viewState->m_viewMode); SetSortOrder(viewState->m_sortOrder); } @@ -219,13 +219,13 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it case NODE_TYPE_TAGS: { SORT_METHOD method = SORT_METHOD_LABEL_IGNORE_THE; - if (!g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (!CSettings::Get().GetBool("filelists.ignorethewhensorting")) method = SORT_METHOD_LABEL; AddSortMethod(method, 551, LABEL_MASKS("%T","", "%T","")); // Title, empty | Title, empty SetSortMethod(method); - - CViewState *viewState = CViewStateSettings::Get().Get("videonavgenres"); + + const CViewState *viewState = CViewStateSettings::Get().Get("videonavgenres"); SetViewAsControl(viewState->m_viewMode); SetSortOrder(viewState->m_sortOrder); } @@ -254,12 +254,12 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it 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")) + if (CSettings::Get().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 - - CViewState *viewState = CViewStateSettings::Get().Get("videonavepisodes"); + + const CViewState *viewState = CViewStateSettings::Get().Get("videonavepisodes"); SetSortMethod(viewState->m_sortMethod); SetViewAsControl(viewState->m_viewMode); SetSortOrder(viewState->m_sortOrder); @@ -281,14 +281,14 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it { AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T", "%R")); // Title, Rating | empty, empty else AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556, LABEL_MASKS("%T", "%R")); // Title, Rating | empty, empty } else { - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating else AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating @@ -302,8 +302,8 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it 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"); + + const CViewState *viewState = CViewStateSettings::Get().Get("videonavtitles"); if (params.GetSetId() > -1) SetSortMethod(SORT_METHOD_YEAR); else @@ -315,13 +315,13 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it break; case NODE_TYPE_TITLE_MUSICVIDEOS: { - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty else AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty AddSortMethod(SORT_METHOD_MPAA_RATING, 20074, LABEL_MASKS("%T", "%O")); AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) { AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 557, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%B - %T", "%Y")); // Album - Title, Year | empty, empty @@ -335,11 +335,11 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it 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"); + CStdString strTrackLeft=CSettings::Get().GetString("musicfiles.trackformat"); + CStdString strTrackRight=CSettings::Get().GetString("musicfiles.trackformatright"); AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined | empty, empty - - CViewState *viewState = CViewStateSettings::Get().Get("videonavmusicvideos"); + + const CViewState *viewState = CViewStateSettings::Get().Get("videonavmusicvideos"); SetSortMethod(viewState->m_sortMethod); SetViewAsControl(viewState->m_viewMode); SetSortOrder(viewState->m_sortOrder); @@ -371,15 +371,15 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it } else { - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%L", "%I", "%L", "")); // Label, Size | Label, empty else AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%L", "%I", "%L", "")); // Label, Size | Label, empty 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 - - CViewState *viewState = CViewStateSettings::Get().Get("videofiles"); + + const CViewState *viewState = CViewStateSettings::Get().Get("videofiles"); SetSortMethod(viewState->m_sortMethod); SetViewAsControl(viewState->m_viewMode); SetSortOrder(viewState->m_sortOrder); @@ -418,7 +418,7 @@ void CGUIViewStateWindowVideoNav::SaveViewState() SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavseasons")); break; case NODE_TYPE_TITLE_MUSICVIDEOS: - SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV,CViewStateSettings::Get().Get("videonavmusicvideos")); + SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavmusicvideos")); break; default: SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV); @@ -436,7 +436,7 @@ VECSOURCES& CGUIViewStateWindowVideoNav::GetSources() // Setup shares we want to have m_sources.clear(); CFileItemList items; - if (g_guiSettings.GetBool("myvideos.flatten")) + if (CSettings::Get().GetBool("myvideos.flatten")) CDirectory::GetDirectory("library://video_flat/", items, ""); else CDirectory::GetDirectory("library://video/", items, ""); @@ -458,9 +458,9 @@ bool CGUIViewStateWindowVideoNav::AutoPlayNextItem() CQueryParams params; CVideoDatabaseDirectory::GetQueryParams(m_items.GetPath(),params); if (params.GetContentType() == VIDEODB_CONTENT_MUSICVIDEOS || params.GetContentType() == 6) // recently added musicvideos - return g_guiSettings.GetBool("musicplayer.autoplaynextitem"); + return CSettings::Get().GetBool("musicplayer.autoplaynextitem"); - return g_guiSettings.GetBool("videoplayer.autoplaynextitem"); + return CSettings::Get().GetBool("videoplayer.autoplaynextitem"); } CGUIViewStateWindowVideoPlaylist::CGUIViewStateWindowVideoPlaylist(const CFileItemList& items) : CGUIViewStateWindowVideo(items) @@ -506,7 +506,7 @@ VECSOURCES& CGUIViewStateWindowVideoPlaylist::GetSources() CGUIViewStateVideoMovies::CGUIViewStateVideoMovies(const CFileItemList& items) : CGUIViewStateWindowVideo(items) { - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating else AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating @@ -514,7 +514,7 @@ 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"); + const 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 @@ -536,13 +536,13 @@ void CGUIViewStateVideoMovies::SaveViewState() CGUIViewStateVideoMusicVideos::CGUIViewStateVideoMusicVideos(const CFileItemList& items) : CGUIViewStateWindowVideo(items) { - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty else AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty AddSortMethod(SORT_METHOD_MPAA_RATING, 20074, LABEL_MASKS("%T", "%O")); AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) { AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 557, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%B - %T", "%Y")); // Album - Title, Year | empty, empty @@ -555,11 +555,11 @@ CGUIViewStateVideoMusicVideos::CGUIViewStateVideoMusicVideos(const CFileItemList 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"); + CStdString strTrackLeft=CSettings::Get().GetString("musicfiles.trackformat"); + CStdString strTrackRight=CSettings::Get().GetString("musicfiles.trackformatright"); AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined | empty, empty - - CViewState *viewState = CViewStateSettings::Get().Get("videonavmusicvideos"); + + const 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 @@ -580,13 +580,13 @@ void CGUIViewStateVideoMusicVideos::SaveViewState() CGUIViewStateVideoTVShows::CGUIViewStateVideoTVShows(const CFileItemList& items) : CGUIViewStateWindowVideo(items) { - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes 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"); + + const 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 @@ -608,7 +608,7 @@ void CGUIViewStateVideoTVShows::SaveViewState() CGUIViewStateVideoEpisodes::CGUIViewStateVideoEpisodes(const CFileItemList& items) : CGUIViewStateWindowVideo(items) { - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%Z - %H. %T","%R")); // TvShow - Order. Title, Rating | empty, empty else AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%Z - %H. %T", "%R")); // TvShow - Order. Title, Rating | empty, empty @@ -628,8 +628,8 @@ 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"); + + const 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 diff --git a/xbmc/video/PlayerController.cpp b/xbmc/video/PlayerController.cpp index d4d8e47d033db..9457d53c3e07d 100644 --- a/xbmc/video/PlayerController.cpp +++ b/xbmc/video/PlayerController.cpp @@ -21,15 +21,16 @@ #include "PlayerController.h" #include "utils/StdString.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" -#include "settings/MediaSettings.h" #include "settings/DisplaySettings.h" +#include "settings/MediaSettings.h" +#include "settings/Settings.h" #include "cores/IPlayer.h" #include "guilib/Key.h" #include "guilib/LocalizeStrings.h" #include "guilib/GUISliderControl.h" #include "dialogs/GUIDialogKaiToast.h" #include "video/dialogs/GUIDialogAudioSubtitleSettings.h" +#include "video/windows/GUIWindowFullScreen.h" #ifdef HAS_VIDEO_PLAYBACK #include "cores/VideoRenderers/RenderManager.h" #endif @@ -275,7 +276,7 @@ bool CPlayerController::OnAction(const CAction &action) case ACTION_SUBTITLE_VSHIFT_UP: { RESOLUTION_INFO& res_info = CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()); - int subalign = g_guiSettings.GetInt("subtitles.align"); + int subalign = CSettings::Get().GetInt("subtitles.align"); if ((subalign == SUBTITLE_ALIGN_BOTTOM_OUTSIDE) || (subalign == SUBTITLE_ALIGN_TOP_INSIDE)) { res_info.iSubtitles ++; @@ -301,7 +302,7 @@ bool CPlayerController::OnAction(const CAction &action) case ACTION_SUBTITLE_VSHIFT_DOWN: { RESOLUTION_INFO& res_info = CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()); - int subalign = g_guiSettings.GetInt("subtitles.align"); + int subalign = CSettings::Get().GetInt("subtitles.align"); if ((subalign == SUBTITLE_ALIGN_BOTTOM_OUTSIDE) || (subalign == SUBTITLE_ALIGN_TOP_INSIDE)) { res_info.iSubtitles--; @@ -327,7 +328,7 @@ bool CPlayerController::OnAction(const CAction &action) case ACTION_SUBTITLE_ALIGN: { RESOLUTION_INFO& res_info = CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()); - int subalign = g_guiSettings.GetInt("subtitles.align"); + int subalign = CSettings::Get().GetInt("subtitles.align"); subalign++; if (subalign > SUBTITLE_ALIGN_TOP_OUTSIDE) @@ -335,7 +336,7 @@ bool CPlayerController::OnAction(const CAction &action) res_info.iSubtitles = res_info.iHeight - 1; - g_guiSettings.SetInt("subtitles.align", subalign); + CSettings::Get().SetInt("subtitles.align", subalign); CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(21460), g_localizeStrings.Get(21461 + subalign), diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp index ad9cf64f4ffa4..ee48d0f58aa3a 100644 --- a/xbmc/video/VideoDatabase.cpp +++ b/xbmc/video/VideoDatabase.cpp @@ -41,7 +41,6 @@ #include "FileItem.h" #include "profiles/ProfilesManager.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" #include "settings/MediaSettings.h" #include "settings/MediaSourceSettings.h" #include "settings/Settings.h" @@ -4243,7 +4242,7 @@ bool CVideoDatabase::UpdateOldVersion(int iVersion) m_pDS->exec("CREATE TRIGGER delete_person AFTER DELETE ON actors FOR EACH ROW BEGIN DELETE FROM art WHERE media_id=old.idActor AND media_type IN ('actor','artist','writer','director'); END"); CMediaSettings::Get().SetVideoNeedsUpdate(63); - g_settings.Save(); + CSettings::Get().Save(); } if (iVersion < 64) { // add idShow to episode table @@ -9668,7 +9667,7 @@ bool CVideoDatabase::GetFilter(CDbUrl &videoUrl, Filter &filter, SortDescription sorting.sortBy = xsp.GetOrder(); if (xsp.GetOrderDirection() != SortOrderNone) sorting.sortOrder = xsp.GetOrderDirection(); - if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) sorting.sortAttributes = SortAttributeIgnoreArticle; } } diff --git a/xbmc/video/VideoInfoScanner.cpp b/xbmc/video/VideoInfoScanner.cpp index 592e6ae47813e..aa9e9df01659c 100644 --- a/xbmc/video/VideoInfoScanner.cpp +++ b/xbmc/video/VideoInfoScanner.cpp @@ -37,7 +37,7 @@ #include "dialogs/GUIDialogOK.h" #include "interfaces/AnnouncementManager.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "utils/StringUtils.h" #include "guilib/LocalizeStrings.h" #include "guilib/GUIWindowManager.h" @@ -81,7 +81,7 @@ namespace VIDEO m_database.Open(); - if (m_showDialog && !g_guiSettings.GetBool("videolibrary.backgroundupdate")) + if (m_showDialog && !CSettings::Get().GetBool("videolibrary.backgroundupdate")) { CGUIDialogExtendedProgressBar* dialog = (CGUIDialogExtendedProgressBar*)g_windowManager.GetWindow(WINDOW_DIALOG_EXT_PROGRESS); @@ -1260,7 +1260,7 @@ namespace VIDEO // parent folder to apply the thumb to and to search for local actor thumbs CStdString parentDir = GetParentDir(*pItem); - if (g_guiSettings.GetBool("videolibrary.actorthumbs")) + if (CSettings::Get().GetBool("videolibrary.actorthumbs")) FetchActorThumbs(movieDetails.m_cast, actorArtPath.empty() ? parentDir : actorArtPath); if (bApplyToDir) ApplyThumbToFolder(parentDir, art["thumb"]); diff --git a/xbmc/video/VideoInfoTag.cpp b/xbmc/video/VideoInfoTag.cpp index d59205d391f60..636f83578a0c7 100644 --- a/xbmc/video/VideoInfoTag.cpp +++ b/xbmc/video/VideoInfoTag.cpp @@ -21,7 +21,6 @@ #include "VideoInfoTag.h" #include "utils/XMLUtils.h" #include "guilib/LocalizeStrings.h" -#include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" #include "utils/log.h" #include "utils/StringUtils.h" diff --git a/xbmc/video/VideoThumbLoader.cpp b/xbmc/video/VideoThumbLoader.cpp index 444e9843ca5ef..a130f57a1e06f 100644 --- a/xbmc/video/VideoThumbLoader.cpp +++ b/xbmc/video/VideoThumbLoader.cpp @@ -25,7 +25,7 @@ #include "filesystem/File.h" #include "filesystem/DirectoryCache.h" #include "FileItem.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "GUIUserMessages.h" #include "guilib/GUIWindowManager.h" #include "TextureCache.h" @@ -284,8 +284,8 @@ bool CVideoThumbLoader::LoadItem(CFileItem* pItem) m_database->SetArtForItem(info->m_iDbId, info->m_type, "thumb", thumbURL); } } - else if (g_guiSettings.GetBool("myvideos.extractthumb") && - g_guiSettings.GetBool("myvideos.extractflags")) + else if (CSettings::Get().GetBool("myvideos.extractthumb") && + CSettings::Get().GetBool("myvideos.extractflags")) { CFileItem item(*pItem); CStdString path(item.GetPath()); @@ -301,7 +301,7 @@ bool CVideoThumbLoader::LoadItem(CFileItem* pItem) } // flag extraction - if (g_guiSettings.GetBool("myvideos.extractflags") && + if (CSettings::Get().GetBool("myvideos.extractflags") && (!pItem->HasVideoInfoTag() || !pItem->GetVideoInfoTag()->HasStreamDetails() || pItem->GetVideoInfoTag()->m_streamDetails.GetVideoDuration() <= 0)) diff --git a/xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp b/xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp index 68fcc0c9c0fdb..d08ce7027f2fb 100644 --- a/xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp +++ b/xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp @@ -33,10 +33,9 @@ #include "addons/Skin.h" #include "profiles/ProfilesManager.h" #include "settings/AdvancedSettings.h" -#include "settings/Settings.h" -#include "settings/GUISettings.h" #include "settings/MediaSettings.h" #include "settings/MediaSourceSettings.h" +#include "settings/Settings.h" #include "guilib/LocalizeStrings.h" #include "pvr/PVRManager.h" #include "cores/AudioEngine/Utils/AEUtil.h" @@ -103,10 +102,10 @@ void CGUIDialogAudioSubtitleSettings::CreateSettings() // 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, &CMediaSettings::Get().GetCurrentVideoSettings().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(CSettings::Get().GetInt("audiooutput.mode"))); int settings[3] = { 338, 339, 420 }; //ANALOG, IEC958, HDMI - m_outputmode = g_guiSettings.GetInt("audiooutput.mode"); + m_outputmode = CSettings::Get().GetInt("audiooutput.mode"); if (SupportsAudioFeature(IPC_AUD_SELECT_OUTPUT)) AddSpin(AUDIO_SETTINGS_DIGITAL_ANALOG, 337, &m_outputmode, 3, settings); @@ -264,7 +263,7 @@ void CGUIDialogAudioSubtitleSettings::OnSettingChanged(SettingInfo &setting) // update the screen setting... CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream = -1 - m_audioStream; // call monkeyh1's code here... - //bool bAudioOnAllSpeakers = (g_guiSettings.GetInt("audiooutput.mode") == AUDIO_IEC958) && CMediaSettings::Get().GetCurrentVideoSettings().m_OutputToAllSpeakers; + //bool bAudioOnAllSpeakers = (CSettings::Get().GetInt("audiooutput.mode") == AUDIO_IEC958) && CMediaSettings::Get().GetCurrentVideoSettings().m_OutputToAllSpeakers; return; } } @@ -286,9 +285,9 @@ void CGUIDialogAudioSubtitleSettings::OnSettingChanged(SettingInfo &setting) switch(m_outputmode) { - case 0: g_guiSettings.SetInt("audiooutput.mode", AUDIO_ANALOG ); break; - case 1: g_guiSettings.SetInt("audiooutput.mode", AUDIO_IEC958 ); bitstream = true; break; - case 2: g_guiSettings.SetInt("audiooutput.mode", AUDIO_HDMI ); bitstream = true; break; + case 0: CSettings::Get().SetInt("audiooutput.mode", AUDIO_ANALOG ); break; + case 1: CSettings::Get().SetInt("audiooutput.mode", AUDIO_IEC958 ); bitstream = true; break; + case 2: CSettings::Get().SetInt("audiooutput.mode", AUDIO_HDMI ); bitstream = true; break; } EnableSettings(AUDIO_SETTINGS_OUTPUT_TO_ALL_SPEAKERS, bitstream); @@ -324,15 +323,15 @@ void CGUIDialogAudioSubtitleSettings::OnSettingChanged(SettingInfo &setting) if (g_application.GetCurrentPlayer() == EPC_DVDPLAYER) strMask = ".srt|.rar|.zip|.ifo|.smi|.sub|.idx|.ass|.ssa|.txt"; VECSOURCES shares(*CMediaSourceSettings::Get().GetSources("video")); - if (CMediaSettings::Get().GetAdditionalSubtitleDirectoryChecked() != -1 && !g_guiSettings.GetString("subtitles.custompath").IsEmpty()) + if (CMediaSettings::Get().GetAdditionalSubtitleDirectoryChecked() != -1 && !CSettings::Get().GetString("subtitles.custompath").empty()) { CMediaSource share; std::vector paths; CStdString strPath1; URIUtils::GetDirectory(strPath,strPath1); paths.push_back(strPath1); - strPath1 = g_guiSettings.GetString("subtitles.custompath"); - paths.push_back(g_guiSettings.GetString("subtitles.custompath")); + strPath1 = CSettings::Get().GetString("subtitles.custompath"); + paths.push_back(CSettings::Get().GetString("subtitles.custompath")); share.FromNameAndPaths("video",g_localizeStrings.Get(21367),paths); shares.push_back(share); strPath = share.strPath; @@ -372,7 +371,7 @@ void CGUIDialogAudioSubtitleSettings::OnSettingChanged(SettingInfo &setting) CMediaSettings::Get().GetDefaultVideoSettings() = CMediaSettings::Get().GetCurrentVideoSettings(); CMediaSettings::Get().GetDefaultVideoSettings().m_SubtitleStream = -1; CMediaSettings::Get().GetDefaultVideoSettings().m_AudioStream = -1; - g_settings.Save(); + CSettings::Get().Save(); } } diff --git a/xbmc/video/dialogs/GUIDialogTeletext.cpp b/xbmc/video/dialogs/GUIDialogTeletext.cpp index a5f238aee678d..bf70623c393cc 100644 --- a/xbmc/video/dialogs/GUIDialogTeletext.cpp +++ b/xbmc/video/dialogs/GUIDialogTeletext.cpp @@ -20,13 +20,13 @@ #include "GUIDialogTeletext.h" #include "utils/log.h" -#include "settings/GUISettings.h" #include "Application.h" #include "guilib/GUITexture.h" #include "guilib/Texture.h" #include "guilib/LocalizeStrings.h" #include "dialogs/GUIDialogKaiToast.h" #include "cores/IPlayer.h" +#include "settings/Settings.h" using namespace std; @@ -119,7 +119,7 @@ void CGUIDialogTeletext::OnInitWindow() m_windowLoaded = true; g_graphicsContext.SetScalingResolution(m_coordsRes, m_needsScaling); - if (g_guiSettings.GetBool("videoplayer.teletextscale")) + if (CSettings::Get().GetBool("videoplayer.teletextscale")) { /* Fixed aspect ratio to 4:3 for teletext */ left = g_graphicsContext.ScaleFinalXCoord((float)(m_coordsRes.iWidth-m_coordsRes.iHeight*4/3)/2, 0); diff --git a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp index eae323e4ec963..d51041c6ef8d7 100644 --- a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp @@ -41,8 +41,8 @@ #include "utils/AsyncFileCopy.h" #include "profiles/ProfilesManager.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" #include "settings/MediaSourceSettings.h" +#include "settings/Settings.h" #include "guilib/Key.h" #include "guilib/LocalizeStrings.h" #include "GUIUserMessages.h" @@ -271,7 +271,7 @@ void CGUIDialogVideoInfo::SetMovie(const CFileItem *item) CFileItemPtr item(new CFileItem(it->strName)); if (!it->thumb.IsEmpty()) item->SetArt("thumb", it->thumb); - else if (g_guiSettings.GetBool("videolibrary.actorthumbs")) + else if (CSettings::Get().GetBool("videolibrary.actorthumbs")) { // backward compatibility CStdString thumb = CScraperUrl::GetThumbURL(it->thumbUrl.GetFirstThumb()); if (!thumb.IsEmpty()) @@ -361,7 +361,7 @@ void CGUIDialogVideoInfo::Update() // setup plot text area CStdString strTmp = m_movieItem->GetVideoInfoTag()->m_strPlot; if (!(!m_movieItem->GetVideoInfoTag()->m_strShowTitle.IsEmpty() && m_movieItem->GetVideoInfoTag()->m_iSeason == 0)) // dont apply to tvshows - if (m_movieItem->GetVideoInfoTag()->m_playCount == 0 && !g_guiSettings.GetBool("videolibrary.showunwatchedplots")) + if (m_movieItem->GetVideoInfoTag()->m_playCount == 0 && !CSettings::Get().GetBool("videolibrary.showunwatchedplots")) strTmp = g_localizeStrings.Get(20370); strTmp.Trim(); diff --git a/xbmc/video/dialogs/GUIDialogVideoSettings.cpp b/xbmc/video/dialogs/GUIDialogVideoSettings.cpp index c90bf49e66bb5..908b911754a11 100644 --- a/xbmc/video/dialogs/GUIDialogVideoSettings.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoSettings.cpp @@ -23,7 +23,6 @@ #include "guilib/GUIWindowManager.h" #include "GUIPassword.h" #include "utils/MathUtils.h" -#include "settings/GUISettings.h" #ifdef HAS_VIDEO_PLAYBACK #include "cores/VideoRenderers/RenderManager.h" #endif @@ -244,7 +243,7 @@ void CGUIDialogVideoSettings::OnSettingChanged(SettingInfo &setting) CMediaSettings::Get().GetDefaultVideoSettings() = CMediaSettings::Get().GetCurrentVideoSettings(); CMediaSettings::Get().GetDefaultVideoSettings().m_SubtitleStream = -1; CMediaSettings::Get().GetDefaultVideoSettings().m_AudioStream = -1; - g_settings.Save(); + CSettings::Get().Save(); } } else if (setting.id == VIDEO_SETTINGS_DEINTERLACEMODE) diff --git a/xbmc/video/windows/GUIWindowFullScreen.cpp b/xbmc/video/windows/GUIWindowFullScreen.cpp index d3786dae341dd..559a04ca7d940 100644 --- a/xbmc/video/windows/GUIWindowFullScreen.cpp +++ b/xbmc/video/windows/GUIWindowFullScreen.cpp @@ -39,14 +39,13 @@ #include "video/dialogs/GUIDialogFullScreenInfo.h" #include "dialogs/GUIDialogNumeric.h" #include "settings/DisplaySettings.h" -#include "settings/Settings.h" #include "settings/MediaSettings.h" +#include "settings/Settings.h" #include "guilib/GUISelectButtonControl.h" #include "FileItem.h" #include "video/VideoReferenceClock.h" #include "settings/AdvancedSettings.h" #include "utils/CPUInfo.h" -#include "settings/GUISettings.h" #include "guilib/LocalizeStrings.h" #include "threads/SingleLock.h" #include "utils/log.h" @@ -252,7 +251,7 @@ bool CGUIWindowFullScreen::OnAction(const CAction &action) } else { - int autoCloseTime = g_guiSettings.GetBool("pvrplayback.confirmchannelswitch") ? 0 : g_advancedSettings.m_iPVRNumericChannelSwitchTimeout; + int autoCloseTime = CSettings::Get().GetBool("pvrplayback.confirmchannelswitch") ? 0 : g_advancedSettings.m_iPVRNumericChannelSwitchTimeout; CStdString strChannel; strChannel.Format("%i", action.GetID() - REMOTE_0); if (CGUIDialogNumeric::ShowAndGetNumber(strChannel, g_localizeStrings.Get(19000), autoCloseTime) || autoCloseTime) @@ -406,12 +405,12 @@ bool CGUIWindowFullScreen::OnMessage(CGUIMessage& message) CSingleLock lock (m_fontLock); CStdString fontPath = "special://xbmc/media/Fonts/"; - fontPath += g_guiSettings.GetString("subtitles.font"); + fontPath += CSettings::Get().GetString("subtitles.font"); // We scale based on PAL4x3 - this at least ensures all sizing is constant across resolutions. RESOLUTION_INFO pal(720, 576, 0); - CGUIFont *subFont = g_fontManager.LoadTTF("__subtitle__", fontPath, color[g_guiSettings.GetInt("subtitles.color")], 0, g_guiSettings.GetInt("subtitles.height"), g_guiSettings.GetInt("subtitles.style"), false, 1.0f, 1.0f, &pal, true); - CGUIFont *borderFont = g_fontManager.LoadTTF("__subtitleborder__", fontPath, 0xFF000000, 0, g_guiSettings.GetInt("subtitles.height"), g_guiSettings.GetInt("subtitles.style"), true, 1.0f, 1.0f, &pal, true); + CGUIFont *subFont = g_fontManager.LoadTTF("__subtitle__", fontPath, color[CSettings::Get().GetInt("subtitles.color")], 0, CSettings::Get().GetInt("subtitles.height"), CSettings::Get().GetInt("subtitles.style"), false, 1.0f, 1.0f, &pal, true); + CGUIFont *borderFont = g_fontManager.LoadTTF("__subtitleborder__", fontPath, 0xFF000000, 0, CSettings::Get().GetInt("subtitles.height"), CSettings::Get().GetInt("subtitles.style"), true, 1.0f, 1.0f, &pal, true); if (!subFont || !borderFont) CLog::Log(LOGERROR, "CGUIWindowFullScreen::OnMessage(WINDOW_INIT) - Unable to load subtitle font"); else @@ -443,7 +442,7 @@ bool CGUIWindowFullScreen::OnMessage(CGUIMessage& message) CGUIWindow::OnMessage(message); - g_settings.Save(); + CSettings::Get().Save(); CSingleLock lock (g_graphicsContext); g_graphicsContext.SetFullScreenVideo(false); @@ -659,7 +658,7 @@ void CGUIWindowFullScreen::FrameMove() strSizing.Format(g_localizeStrings.Get(245), (int)info.SrcRect.Width(), (int)info.SrcRect.Height(), (int)(info.DestRect.Width() * xscale), (int)(info.DestRect.Height() * yscale), - CDisplaySettings::Get().GetZoomAmount(), info.videoAspectRatio*CDisplaySettings::Get().GetPixelRatio(), + CDisplaySettings::Get().GetZoomAmount(), info.videoAspectRatio*CDisplaySettings::Get().GetPixelRatio(), CDisplaySettings::Get().GetPixelRatio(), CDisplaySettings::Get().GetVerticalShift()); CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW2); msg.SetLabel(strSizing); @@ -806,7 +805,7 @@ void CGUIWindowFullScreen::RenderTTFSubtitles() float maxWidth = (float) CDisplaySettings::Get().GetResolutionInfo(res).Overscan.right - CDisplaySettings::Get().GetResolutionInfo(res).Overscan.left; m_subsLayout->Update(subtitleText, maxWidth * 0.9f, false, true); // true to force LTR reading order (most Hebrew subs are this format) - int subalign = g_guiSettings.GetInt("subtitles.align"); + int subalign = CSettings::Get().GetInt("subtitles.align"); float textWidth, textHeight; m_subsLayout->GetTextExtent(textWidth, textHeight); float x = maxWidth * 0.5f + CDisplaySettings::Get().GetResolutionInfo(res).Overscan.left; diff --git a/xbmc/video/windows/GUIWindowFullScreen.h b/xbmc/video/windows/GUIWindowFullScreen.h index c0df83491f112..c42a09551c560 100644 --- a/xbmc/video/windows/GUIWindowFullScreen.h +++ b/xbmc/video/windows/GUIWindowFullScreen.h @@ -23,6 +23,15 @@ #include "guilib/GUIWindow.h" #include "threads/CriticalSection.h" +enum SubtitleAlign +{ + SUBTITLE_ALIGN_MANUAL = 0, + SUBTITLE_ALIGN_BOTTOM_INSIDE, + SUBTITLE_ALIGN_BOTTOM_OUTSIDE, + SUBTITLE_ALIGN_TOP_INSIDE, + SUBTITLE_ALIGN_TOP_OUTSIDE +}; + class CGUITextLayout; // forward class CGUIWindowFullScreen : public CGUIWindow diff --git a/xbmc/video/windows/GUIWindowVideoBase.cpp b/xbmc/video/windows/GUIWindowVideoBase.cpp index 212a3b47e7b96..a1a0bc33a29c9 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.cpp +++ b/xbmc/video/windows/GUIWindowVideoBase.cpp @@ -55,7 +55,6 @@ #include "profiles/ProfilesManager.h" #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" @@ -145,10 +144,10 @@ bool CGUIWindowVideoBase::OnMessage(CGUIMessage& message) m_dlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); // save current window, unless the current window is the video playlist window - if (GetID() != WINDOW_VIDEO_PLAYLIST && g_guiSettings.GetInt("myvideos.startwindow") != GetID()) + if (GetID() != WINDOW_VIDEO_PLAYLIST && CSettings::Get().GetInt("myvideos.startwindow") != GetID()) { - g_guiSettings.SetInt("myvideos.startwindow", GetID()); - g_settings.Save(); + CSettings::Get().SetInt("myvideos.startwindow", GetID()); + CSettings::Get().Save(); } return CGUIMediaWindow::OnMessage(message); @@ -160,8 +159,8 @@ bool CGUIWindowVideoBase::OnMessage(CGUIMessage& message) int iControl = message.GetSenderId(); if (iControl == CONTROL_STACK) { - g_guiSettings.ToggleBool("myvideos.stackvideos"); - g_settings.Save(); + CSettings::Get().ToggleBool("myvideos.stackvideos"); + CSettings::Get().Save(); UpdateButtons(); Update( m_vecItems->GetPath() ); } @@ -191,8 +190,8 @@ bool CGUIWindowVideoBase::OnMessage(CGUIMessage& message) if (nNewWindow != GetID()) { - g_guiSettings.SetInt("myvideos.startwindow", nNewWindow); - g_settings.Save(); + CSettings::Get().SetInt("myvideos.startwindow", nNewWindow); + CSettings::Get().Save(); g_windowManager.ChangeActiveWindow(nNewWindow); CGUIMessage msg2(GUI_MSG_SETFOCUS, nNewWindow, CONTROL_BTNTYPE); g_windowManager.SendMessage(msg2); @@ -230,7 +229,7 @@ bool CGUIWindowVideoBase::OnMessage(CGUIMessage& message) OnDeleteItem(iItem); // or be at the files window and have file deletion enabled - else if (GetID() == WINDOW_VIDEO_FILES && g_guiSettings.GetBool("filelists.allowfiledeletion")) + else if (GetID() == WINDOW_VIDEO_FILES && CSettings::Get().GetBool("filelists.allowfiledeletion")) OnDeleteItem(iItem); // or be at the video playlists location @@ -269,13 +268,13 @@ void CGUIWindowVideoBase::UpdateButtons() g_windowManager.SendMessage(msg2); // Select the current window as default item - int nWindow = g_guiSettings.GetInt("myvideos.startwindow")-WINDOW_VIDEO_FILES; + int nWindow = CSettings::Get().GetInt("myvideos.startwindow")-WINDOW_VIDEO_FILES; CONTROL_SELECT_ITEM(CONTROL_BTNTYPE, nWindow); CONTROL_ENABLE(CONTROL_BTNSCAN); SET_CONTROL_LABEL(CONTROL_STACK, 14000); // Stack - SET_CONTROL_SELECTED(GetID(), CONTROL_STACK, g_guiSettings.GetBool("myvideos.stackvideos")); + SET_CONTROL_SELECTED(GetID(), CONTROL_STACK, CSettings::Get().GetBool("myvideos.stackvideos")); CONTROL_ENABLE_ON_CONDITION(CONTROL_STACK, m_stackingAvailable); CGUIMediaWindow::UpdateButtons(); @@ -918,7 +917,7 @@ bool CGUIWindowVideoBase::OnSelect(int iItem) CStdString path = item->GetPath(); if (!item->m_bIsFolder && path != "add" && path != "addons://more/video" && path.Left(19) != "newsmartplaylist://" && path.Left(14) != "newplaylist://" && path.Left(9) != "newtag://") - return OnFileAction(iItem, g_guiSettings.GetInt("myvideos.selectaction")); + return OnFileAction(iItem, CSettings::Get().GetInt("myvideos.selectaction")); return CGUIMediaWindow::OnSelect(iItem); } @@ -1280,7 +1279,7 @@ void CGUIWindowVideoBase::GetContextButtons(int itemNumber, CContextButtons &but //then add add either 'play from here' or 'play only this' depending on default behaviour if (!(item->m_bIsFolder || item->IsScript()) && m_vecItems->Size() > 1 && itemNumber < m_vecItems->Size()-1) { - if (!g_guiSettings.GetBool("videoplayer.autoplaynextitem")) + if (!CSettings::Get().GetBool("videoplayer.autoplaynextitem")) buttons.Add(CONTEXT_BUTTON_PLAY_AND_QUEUE, 13412); else buttons.Add(CONTEXT_BUTTON_PLAY_ONLY_THIS, 13434); @@ -1649,7 +1648,7 @@ void CGUIWindowVideoBase::OnDeleteItem(CFileItemPtr item) return; } - if ((g_guiSettings.GetBool("filelists.allowfiledeletion") || + if ((CSettings::Get().GetBool("filelists.allowfiledeletion") || m_vecItems->GetPath().Equals("special://videoplaylists/")) && CUtil::SupportsWriteFileOperations(item->GetPath())) CFileUtils::DeleteItem(item); @@ -1876,7 +1875,7 @@ bool CGUIWindowVideoBase::GetDirectory(const CStdString &strDirectory, CFileItem if (info && info->Content() == CONTENT_TVSHOWS) m_stackingAvailable = false; - if (m_stackingAvailable && !items.IsStack() && g_guiSettings.GetBool("myvideos.stackvideos")) + if (m_stackingAvailable && !items.IsStack() && CSettings::Get().GetBool("myvideos.stackvideos")) items.Stack(); return bResult; @@ -1911,7 +1910,7 @@ void CGUIWindowVideoBase::GetGroupedItems(CFileItemList &items) VIDEODATABASEDIRECTORY::NODE_TYPE nodeType = CVideoDatabaseDirectory::GetDirectoryChildType(m_strFilterPath); if (items.GetContent().Equals("movies") && params.GetSetId() <= 0 && nodeType == NODE_TYPE_TITLE_MOVIES && - (g_guiSettings.GetBool("videolibrary.groupmoviesets") || (StringUtils::EqualsNoCase(group, "sets") && mixed))) + (CSettings::Get().GetBool("videolibrary.groupmoviesets") || (StringUtils::EqualsNoCase(group, "sets") && mixed))) { CFileItemList groupedItems; if (GroupUtils::Group(GroupBySet, m_strFilterPath, items, groupedItems, GroupAttributeIgnoreSingleItems)) @@ -2073,7 +2072,7 @@ void CGUIWindowVideoBase::OnSearchItemFound(const CFileItem* pSelItem) Update(strParentPath); - if (pSelItem->IsVideoDb() && g_guiSettings.GetBool("myvideos.flatten")) + if (pSelItem->IsVideoDb() && CSettings::Get().GetBool("myvideos.flatten")) SetHistoryForPath(""); else SetHistoryForPath(strParentPath); @@ -2100,7 +2099,7 @@ void CGUIWindowVideoBase::OnSearchItemFound(const CFileItem* pSelItem) Update(strPath); - if (pSelItem->IsVideoDb() && g_guiSettings.GetBool("myvideos.flatten")) + if (pSelItem->IsVideoDb() && CSettings::Get().GetBool("myvideos.flatten")) SetHistoryForPath(""); else SetHistoryForPath(strPath); @@ -2161,7 +2160,7 @@ void CGUIWindowVideoBase::AppendAndClearSearchItems(CFileItemList &searchItems, if (!searchItems.Size()) return; - searchItems.Sort(g_guiSettings.GetBool("filelists.ignorethewhensorting") ? SORT_METHOD_LABEL_IGNORE_THE : SORT_METHOD_LABEL, SortOrderAscending); + searchItems.Sort(CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SORT_METHOD_LABEL_IGNORE_THE : SORT_METHOD_LABEL, SortOrderAscending); for (int i = 0; i < searchItems.Size(); i++) searchItems[i]->SetLabel(prependLabel + searchItems[i]->GetLabel()); results.Append(searchItems); @@ -2240,7 +2239,7 @@ void CGUIWindowVideoBase::OnInitWindow() { CEdenVideoArtUpdater::Start(); CMediaSettings::Get().SetVideoNeedsUpdate(0); // once is enough - g_settings.Save(); + CSettings::Get().Save(); } } } diff --git a/xbmc/video/windows/GUIWindowVideoBase.h b/xbmc/video/windows/GUIWindowVideoBase.h index 06c75f53c5a63..c77a2ac574c8e 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.h +++ b/xbmc/video/windows/GUIWindowVideoBase.h @@ -25,6 +25,17 @@ #include "PlayListPlayer.h" #include "video/VideoThumbLoader.h" +enum VideoSelectAction +{ + SELECT_ACTION_CHOOSE = 0, + SELECT_ACTION_PLAY_OR_RESUME, + SELECT_ACTION_RESUME, + SELECT_ACTION_INFO, + SELECT_ACTION_MORE, + SELECT_ACTION_PLAY, + SELECT_ACTION_PLAYPART +}; + class CGUIWindowVideoBase : public CGUIMediaWindow, public IBackgroundLoaderObserver, public IStreamDetailsObserver { public: diff --git a/xbmc/video/windows/GUIWindowVideoNav.cpp b/xbmc/video/windows/GUIWindowVideoNav.cpp index 1bb17f0ff7a2c..44308ff97c9b2 100644 --- a/xbmc/video/windows/GUIWindowVideoNav.cpp +++ b/xbmc/video/windows/GUIWindowVideoNav.cpp @@ -42,11 +42,10 @@ #include "Application.h" #include "ApplicationMessenger.h" #include "profiles/ProfilesManager.h" -#include "settings/Settings.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" #include "settings/MediaSettings.h" #include "settings/MediaSourceSettings.h" +#include "settings/Settings.h" #include "guilib/Key.h" #include "guilib/LocalizeStrings.h" #include "storage/MediaManager.h" @@ -121,7 +120,7 @@ bool CGUIWindowVideoNav::OnMessage(CGUIMessage& message) /* We don't want to show Autosourced items (ie removable pendrives, memorycards) in Library mode */ m_rootDir.AllowNonLocalSources(false); - SetProperty("flattened", g_guiSettings.GetBool("myvideos.flatten")); + SetProperty("flattened", CSettings::Get().GetBool("myvideos.flatten")); if (message.GetNumStringParams() && message.GetStringParam(0).Equals("Files") && CMediaSourceSettings::Get().GetSources("video")->empty()) { @@ -165,15 +164,15 @@ bool CGUIWindowVideoNav::OnMessage(CGUIMessage& message) else if (iControl == CONTROL_BTNSHOWMODE) { CMediaSettings::Get().CycleWatchedMode(m_vecItems->GetContent()); - g_settings.Save(); + CSettings::Get().Save(); OnFilterItems(GetProperty("filter").asString()); return true; } else if (iControl == CONTROL_BTNFLATTEN) { - g_guiSettings.ToggleBool("myvideos.flatten"); - g_settings.Save(); - SetProperty("flattened", g_guiSettings.GetBool("myvideos.flatten")); + CSettings::Get().ToggleBool("myvideos.flatten"); + CSettings::Get().Save(); + SetProperty("flattened", CSettings::Get().GetBool("myvideos.flatten")); CUtil::DeleteVideoDatabaseDirectoryCache(); SetupShares(); Update(""); @@ -185,7 +184,7 @@ bool CGUIWindowVideoNav::OnMessage(CGUIMessage& message) CMediaSettings::Get().SetWatchedMode(m_vecItems->GetContent(), WatchedModeUnwatched); else CMediaSettings::Get().SetWatchedMode(m_vecItems->GetContent(), WatchedModeAll); - g_settings.Save(); + CSettings::Get().Save(); OnFilterItems(GetProperty("filter").asString()); return true; } @@ -423,8 +422,8 @@ void CGUIWindowVideoNav::LoadVideoInfo(CFileItemList &items, CVideoDatabase &dat Similarly, we assign the "clean" library labels to the item only if the "Replace filenames with library titles" setting is enabled. */ - const bool stackItems = items.GetProperty("isstacked").asBoolean() || (StackingAvailable(items) && g_guiSettings.GetBool("myvideos.stackvideos")); - const bool replaceLabels = allowReplaceLabels && g_guiSettings.GetBool("myvideos.replacelabels"); + const bool stackItems = items.GetProperty("isstacked").asBoolean() || (StackingAvailable(items) && CSettings::Get().GetBool("myvideos.stackvideos")); + const bool replaceLabels = allowReplaceLabels && CSettings::Get().GetBool("myvideos.replacelabels"); CFileItemList dbItems; /* NOTE: In the future when GetItemsForPath returns all items regardless of whether they're "in the library" @@ -541,7 +540,7 @@ void CGUIWindowVideoNav::UpdateButtons() SET_CONTROL_SELECTED(GetID(),CONTROL_BTNPARTYMODE, g_partyModeManager.IsEnabled()); - SET_CONTROL_SELECTED(GetID(),CONTROL_BTNFLATTEN, g_guiSettings.GetBool("myvideos.flatten")); + SET_CONTROL_SELECTED(GetID(),CONTROL_BTNFLATTEN, CSettings::Get().GetBool("myvideos.flatten")); } bool CGUIWindowVideoNav::GetFilteredItems(const CStdString &filter, CFileItemList &items) @@ -743,7 +742,7 @@ void CGUIWindowVideoNav::OnDeleteItem(CFileItemPtr pItem) if (URIUtils::HasSlashAtEnd(strDeletePath)) pItem->m_bIsFolder=true; - if (g_guiSettings.GetBool("filelists.allowfiledeletion") && + if (CSettings::Get().GetBool("filelists.allowfiledeletion") && CUtil::SupportsWriteFileOperations(strDeletePath)) { pItem->SetPath(strDeletePath); @@ -1045,7 +1044,7 @@ void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &butt if (!m_vecItems->IsVideoDb() && !m_vecItems->IsVirtualDirectoryRoot()) { // non-video db items, file operations are allowed - if ((g_guiSettings.GetBool("filelists.allowfiledeletion") && + if ((CSettings::Get().GetBool("filelists.allowfiledeletion") && CUtil::SupportsWriteFileOperations(item->GetPath())) || (inPlaylists && !URIUtils::GetFileName(item->GetPath()).Equals("PartyMode-Video.xsp") && (item->IsPlayList() || item->IsSmartPlayList()))) @@ -1539,7 +1538,7 @@ void CGUIWindowVideoNav::OnLinkMovieToTvShow(int itemnumber, bool bRemove) int iSelectedLabel = 0; if (list.Size() > 1) { - list.Sort(g_guiSettings.GetBool("filelists.ignorethewhensorting") ? SORT_METHOD_LABEL_IGNORE_THE : SORT_METHOD_LABEL, SortOrderAscending); + list.Sort(CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SORT_METHOD_LABEL_IGNORE_THE : SORT_METHOD_LABEL, SortOrderAscending); CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDialog->Reset(); pDialog->SetItems(&list); diff --git a/xbmc/video/windows/GUIWindowVideoPlaylist.cpp b/xbmc/video/windows/GUIWindowVideoPlaylist.cpp index 5d6e2bdd71363..c833733c07325 100644 --- a/xbmc/video/windows/GUIWindowVideoPlaylist.cpp +++ b/xbmc/video/windows/GUIWindowVideoPlaylist.cpp @@ -30,9 +30,8 @@ #include "guilib/GUIKeyboardFactory.h" #include "GUIUserMessages.h" #include "Favourites.h" -#include "settings/Settings.h" -#include "settings/GUISettings.h" #include "settings/MediaSettings.h" +#include "settings/Settings.h" #include "guilib/Key.h" #include "guilib/LocalizeStrings.h" #include "utils/log.h" @@ -129,7 +128,7 @@ bool CGUIWindowVideoPlaylist::OnMessage(CGUIMessage& message) { g_playlistPlayer.SetShuffle(PLAYLIST_VIDEO, !(g_playlistPlayer.IsShuffled(PLAYLIST_VIDEO))); CMediaSettings::Get().SetVideoPlaylistShuffled(g_playlistPlayer.IsShuffled(PLAYLIST_VIDEO)); - g_settings.Save(); + CSettings::Get().Save(); UpdateButtons(); Refresh(); } @@ -172,7 +171,7 @@ bool CGUIWindowVideoPlaylist::OnMessage(CGUIMessage& message) // save settings CMediaSettings::Get().SetVideoPlaylistRepeat(g_playlistPlayer.GetRepeat(PLAYLIST_VIDEO) == PLAYLIST::REPEAT_ALL); - g_settings.Save(); + CSettings::Get().Save(); UpdateButtons(); } @@ -377,7 +376,7 @@ void CGUIWindowVideoPlaylist::SavePlayList() { // need 2 rename it CStdString strPath, strFolder; - URIUtils::AddFileToFolder(g_guiSettings.GetString("system.playlistspath"), "video", strFolder); + URIUtils::AddFileToFolder(CSettings::Get().GetString("system.playlistspath"), "video", strFolder); strNewFileName = CUtil::MakeLegalFileName(strNewFileName); strNewFileName += ".m3u"; URIUtils::AddFileToFolder(strFolder, strNewFileName, strPath); diff --git a/xbmc/view/GUIViewState.cpp b/xbmc/view/GUIViewState.cpp index 39b02db9a9b2b..8f6e6cda0305a 100644 --- a/xbmc/view/GUIViewState.cpp +++ b/xbmc/view/GUIViewState.cpp @@ -37,7 +37,6 @@ #include "addons/AddonManager.h" #include "addons/PluginSource.h" #include "view/ViewState.h" -#include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" #include "settings/MediaSourceSettings.h" #include "settings/Settings.h" @@ -260,7 +259,7 @@ void CGUIViewState::AddSortMethod(SORT_METHOD sortMethod, int buttonLabel, LABEL void CGUIViewState::SetCurrentSortMethod(int method) { - bool ignoreThe = g_guiSettings.GetBool("filelists.ignorethewhensorting"); + bool ignoreThe = CSettings::Get().GetBool("filelists.ignorethewhensorting"); if (method < SORT_METHOD_NONE || method >= SORT_METHOD_MAX) return; // invalid @@ -303,18 +302,18 @@ SORT_METHOD CGUIViewState::SetNextSortMethod(int direction /* = 1 */) bool CGUIViewState::HideExtensions() { - return !g_guiSettings.GetBool("filelists.showextensions"); + return !CSettings::Get().GetBool("filelists.showextensions"); } bool CGUIViewState::HideParentDirItems() { - return !g_guiSettings.GetBool("filelists.showparentdiritems"); + return !CSettings::Get().GetBool("filelists.showparentdiritems"); } bool CGUIViewState::DisableAddSourceButtons() { if (CProfilesManager::Get().GetCurrentProfile().canWriteSources() || g_passwordManager.bMasterUser) - return !g_guiSettings.GetBool("filelists.showaddsourcebuttons"); + return !CSettings::Get().GetBool("filelists.showaddsourcebuttons"); return true; } @@ -449,7 +448,7 @@ void CGUIViewState::LoadViewState(const CStdString &path, int windowID) if (db.Open()) { CViewState state; - if (db.GetViewState(path, windowID, state, g_guiSettings.GetString("lookandfeel.skin")) || + if (db.GetViewState(path, windowID, state, CSettings::Get().GetString("lookandfeel.skin")) || db.GetViewState(path, windowID, state, "")) { SetViewAsControl(state.m_viewMode); @@ -468,10 +467,10 @@ void CGUIViewState::SaveViewToDb(const CStdString &path, int windowID, CViewStat CViewState state(m_currentViewAsControl, GetSortMethod(), m_sortOrder); if (viewState) *viewState = state; - db.SetViewState(path, windowID, state, g_guiSettings.GetString("lookandfeel.skin")); + db.SetViewState(path, windowID, state, CSettings::Get().GetString("lookandfeel.skin")); db.Close(); if (viewState) - g_settings.Save(); + CSettings::Get().Save(); } } @@ -485,7 +484,7 @@ void CGUIViewState::AddPlaylistOrder(const CFileItemList &items, LABEL_MASKS lab SortBy sortBy = (SortBy)items.GetProperty(PROPERTY_SORT_ORDER).asInteger(); if (sortBy != SortByNone) { - sortMethod = SortUtils::TranslateOldSortMethod(sortBy, g_guiSettings.GetBool("filelists.ignorethewhensorting")); + sortMethod = SortUtils::TranslateOldSortMethod(sortBy, CSettings::Get().GetBool("filelists.ignorethewhensorting")); if (sortMethod == SORT_METHOD_NONE) sortMethod = SORT_METHOD_PLAYLIST_ORDER; else diff --git a/xbmc/view/ViewStateSettings.cpp b/xbmc/view/ViewStateSettings.cpp index 0df7b8c290be1..9e78b9c245e81 100644 --- a/xbmc/view/ViewStateSettings.cpp +++ b/xbmc/view/ViewStateSettings.cpp @@ -31,6 +31,8 @@ #define XML_VIEWMODE "viewmode" #define XML_SORTMETHOD "sortmethod" #define XML_SORTORDER "sortorder" +#define XML_GENERAL "general" +#define XML_SETTINGLEVEL "settinglevel" using namespace std; @@ -53,6 +55,8 @@ CViewStateSettings::CViewStateSettings() AddViewState("pictures", DEFAULT_VIEW_AUTO); AddViewState("videofiles", DEFAULT_VIEW_AUTO); AddViewState("musicfiles", DEFAULT_VIEW_AUTO); + + Clear(); } CViewStateSettings::~CViewStateSettings() @@ -98,6 +102,16 @@ bool CViewStateSettings::Load(const TiXmlNode *settings) viewState->second->m_sortOrder = (SortOrder)sortOrder; } + pElement = settings->FirstChild(XML_GENERAL); + if (pElement != NULL) + { + int settingLevel; + if (XMLUtils::GetInt(pElement, XML_SETTINGLEVEL, settingLevel, (const int)SettingLevelBasic, (const int)SettingLevelExpert)) + m_settingLevel = (SettingLevel)settingLevel; + else + m_settingLevel = SettingLevelStandard; + } + return true; } @@ -126,12 +140,27 @@ bool CViewStateSettings::Save(TiXmlNode *settings) const 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); + } + TiXmlNode *generalNode = settings->FirstChild(XML_GENERAL); + if (generalNode == NULL) + { + TiXmlElement generalElement(XML_GENERAL); + generalNode = settings->InsertEndChild(generalElement); + if (generalNode == NULL) + return false; } + XMLUtils::SetInt(generalNode, XML_SETTINGLEVEL, (int)m_settingLevel); + return true; } +void CViewStateSettings::Clear() +{ + m_settingLevel = SettingLevelStandard; +} + const CViewState* CViewStateSettings::Get(const std::string &viewState) const { CSingleLock lock(m_critical); @@ -152,6 +181,23 @@ CViewState* CViewStateSettings::Get(const std::string &viewState) return NULL; } +void CViewStateSettings::SetSettingLevel(SettingLevel settingLevel) +{ + if (settingLevel < SettingLevelBasic) + m_settingLevel = SettingLevelBasic; + if (settingLevel > SettingLevelExpert) + m_settingLevel = SettingLevelExpert; + else + m_settingLevel = settingLevel; +} + +void CViewStateSettings::CycleSettingLevel() +{ + m_settingLevel = (SettingLevel)((int)m_settingLevel + 1); + if (m_settingLevel > SettingLevelExpert) + m_settingLevel = SettingLevelBasic; +} + 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()) diff --git a/xbmc/view/ViewStateSettings.h b/xbmc/view/ViewStateSettings.h index b2174a571ae45..5014d2dbc0e41 100644 --- a/xbmc/view/ViewStateSettings.h +++ b/xbmc/view/ViewStateSettings.h @@ -25,6 +25,7 @@ #include "ViewState.h" #include "guilib/GraphicContext.h" #include "settings/ISubSettings.h" +#include "settings/Setting.h" #include "threads/CriticalSection.h" class TiXmlNode; @@ -36,10 +37,15 @@ class CViewStateSettings : public ISubSettings virtual bool Load(const TiXmlNode *settings); virtual bool Save(TiXmlNode *settings) const; + virtual void Clear(); const CViewState* Get(const std::string &viewState) const; CViewState* Get(const std::string &viewState); + SettingLevel GetSettingLevel() const { return m_settingLevel; } + void SetSettingLevel(SettingLevel settingLevel); + void CycleSettingLevel(); + protected: CViewStateSettings(); CViewStateSettings(const CViewStateSettings&); @@ -48,6 +54,7 @@ class CViewStateSettings : public ISubSettings private: std::map m_viewStates; + SettingLevel m_settingLevel; CCriticalSection m_critical; void AddViewState(const std::string& strTagName, int defaultView = DEFAULT_VIEW_LIST, SORT_METHOD defaultSort = SORT_METHOD_LABEL); diff --git a/xbmc/visualizations/Vortex/VortexVis/Core/Vortex.cpp b/xbmc/visualizations/Vortex/VortexVis/Core/Vortex.cpp index 6bc8ad673929b..682724e35d20a 100644 --- a/xbmc/visualizations/Vortex/VortexVis/Core/Vortex.cpp +++ b/xbmc/visualizations/Vortex/VortexVis/Core/Vortex.cpp @@ -359,7 +359,7 @@ void Vortex::Init( LPDIRECT3DDEVICE9 pD3DDevice, int iPosX, int iPosY, int iWidt g_AnnouncePreset.Init(m_pScriptEngine, "ANNOUNCE"); g_AnnouncePreset.m_presetId = 3; - if ( g_Settings.PresetLocked ) + if ( CSettings::Get().PresetLocked ) { // Check that the preset locked in the settings file is still valid if ( g_currPresetId >= g_PresetFiles.NumFiles() || g_currPresetId < 0 ) @@ -367,7 +367,7 @@ void Vortex::Init( LPDIRECT3DDEVICE9 pD3DDevice, int iPosX, int iPosY, int iWidt g_currPresetId = GetRandomPreset(); } } - else if ( g_Settings.RandomPresetsEnabled ) + else if ( CSettings::Get().RandomPresetsEnabled ) { g_currPresetId = GetRandomPreset(); } @@ -379,7 +379,7 @@ void Vortex::Init( LPDIRECT3DDEVICE9 pD3DDevice, int iPosX, int iPosY, int iWidt char filename[ 256 ]; sprintf( filename, "%s%s", g_PresetPath, g_PresetFiles.GetFilename( g_currPresetId ) ); g_presets[ 0 ]->Begin( filename ); - g_mainCounter = g_Settings.TimeBetweenPresets + ((rand() % 100) / 100.0f) * g_Settings.TimeBetweenPresetsRand; + g_mainCounter = CSettings::Get().TimeBetweenPresets + ((rand() % 100) / 100.0f) * CSettings::Get().TimeBetweenPresetsRand; g_currentState = STATE_RENDER_PRESET; } @@ -809,7 +809,7 @@ void Vortex::Render() case STATE_RENDER_PRESET: { // OutputDebugString("STATE = STATE_RENDER_PRESET\n"); - if ( !g_Settings.PresetLocked ) + if ( !CSettings::Get().PresetLocked ) { g_mainCounter -= g_timePass; } @@ -821,7 +821,7 @@ void Vortex::Render() if ( g_mainCounter <= 0 ) { // Not in a transition, preset not locked and time for a new preset - if ( g_Settings.RandomPresetsEnabled ) + if ( CSettings::Get().RandomPresetsEnabled ) { int nextPreset = GetRandomPreset(); if ( nextPreset == g_currPresetId ) @@ -843,14 +843,14 @@ void Vortex::Render() } g_finished = true; - g_mainCounter = g_Settings.TimeBetweenPresets + ((rand() % 100) / 100.0f) * g_Settings.TimeBetweenPresetsRand; + g_mainCounter = CSettings::Get().TimeBetweenPresets + ((rand() % 100) / 100.0f) * CSettings::Get().TimeBetweenPresetsRand; // Load preset sprintf(filename, "%s%s", g_PresetPath, g_PresetFiles.GetFilename( g_currPresetId ) ); if ( g_presets[ 1 ]->Begin( filename ) == true ) { // Load and begin transition - if ( g_Settings.TransitionsEnabled && g_TransitionFiles.NumFiles() != 0 ) + if ( CSettings::Get().TransitionsEnabled && g_TransitionFiles.NumFiles() != 0 ) { g_transitionId = ( g_transitionId + 1 ) % g_TransitionFiles.NumFiles(); sprintf( filename, "%s%s", g_TransitionPath, g_TransitionFiles.GetFilename( g_transitionId ) ); @@ -880,7 +880,7 @@ void Vortex::Render() // OutputDebugString("STATE = STATE_TRANSITION\n"); if (g_finished) { - g_mainCounter = g_Settings.TimeBetweenPresets + ((rand() % 100) / 100.0f) * g_Settings.TimeBetweenPresetsRand; + g_mainCounter = CSettings::Get().TimeBetweenPresets + ((rand() % 100) / 100.0f) * CSettings::Get().TimeBetweenPresetsRand; SwapPresets(); g_finished = false; @@ -913,7 +913,7 @@ void Vortex::Render() // Renderer::Rect( -1.0, -1.0, 1.0, 1.0, 0xff000000 ); /* - if ( g_Settings.ShowAudioAnalysis ) + if ( CSettings::Get().ShowAudioAnalysis ) { FLOAT BAR_WIDTH = 1.0f / 128; / * @@ -994,12 +994,12 @@ void Vortex::Render() } */ - if( g_Settings.ShowDebugConsole ) + if( CSettings::Get().ShowDebugConsole ) { DebugConsole::Render(); } - if( g_Settings.ShowFPS ) + if( CSettings::Get().ShowFPS ) { char FrameRate[256]; sprintf_s(FrameRate, 256, "FPS = %0.02f\n", fFPS ); diff --git a/xbmc/win32/WIN32Util.cpp b/xbmc/win32/WIN32Util.cpp index 0ca4e474eef4f..d0585e50c0ad7 100644 --- a/xbmc/win32/WIN32Util.cpp +++ b/xbmc/win32/WIN32Util.cpp @@ -19,7 +19,6 @@ */ #include "WIN32Util.h" -#include "settings/GUISettings.h" #include "Util.h" #include "utils/URIUtils.h" #include "storage/cdioSupport.h" @@ -1604,4 +1603,4 @@ bool CWIN32Util::IsUsbDevice(const CStdStringW &strWdrive) CloseHandle(deviceHandle); return BusTypeUsb == busType; - } \ No newline at end of file + } diff --git a/xbmc/win32/WIN32Util.h b/xbmc/win32/WIN32Util.h index eb7a50cd7d898..40f3cc5d2a3f7 100644 --- a/xbmc/win32/WIN32Util.h +++ b/xbmc/win32/WIN32Util.h @@ -21,13 +21,13 @@ */ #include "URL.h" -#include "settings/GUISettings.h" #if _MSC_VER > 1400 #include "Cfgmgr32.h" #endif #include "MediaSource.h" -#include "utils/Stopwatch.h" #include "guilib/Geometry.h" +#include "powermanagement/PowerManager.h" +#include "utils/Stopwatch.h" enum Drive_Types { diff --git a/xbmc/win32/XBMC_PC.cpp b/xbmc/win32/XBMC_PC.cpp index 425e3f1720714..d3823c9af0912 100644 --- a/xbmc/win32/XBMC_PC.cpp +++ b/xbmc/win32/XBMC_PC.cpp @@ -18,8 +18,8 @@ * */ -#include "settings/AdvancedSettings.h" #include "AppParamParser.h" +#include "settings/AdvancedSettings.h" #include "utils/CharsetConverter.h" #include "utils/log.h" #include "threads/platform/win/Win32Exception.h" diff --git a/xbmc/windowing/WinSystem.cpp b/xbmc/windowing/WinSystem.cpp index 08478948e4d2e..b60dfe3071285 100644 --- a/xbmc/windowing/WinSystem.cpp +++ b/xbmc/windowing/WinSystem.cpp @@ -22,7 +22,6 @@ #include "guilib/GraphicContext.h" #include "settings/DisplaySettings.h" #include "settings/Settings.h" -#include "settings/GUISettings.h" using namespace std; @@ -207,8 +206,8 @@ REFRESHRATE CWinSystemBase::DefaultRefreshRate(int screen, vector r bool CWinSystemBase::UseLimitedColor() { #if defined(HAS_GL) || defined(HAS_DX) - static CSettingBool* setting = (CSettingBool*)g_guiSettings.GetSetting("videoscreen.limitedrange"); - return setting->GetData(); + static CSettingBool* setting = (CSettingBool*)CSettings::Get().GetSetting("videoscreen.limitedrange"); + return setting->GetValue(); #else return false; #endif diff --git a/xbmc/windowing/X11/WinSystemX11GLES.cpp b/xbmc/windowing/X11/WinSystemX11GLES.cpp index 7975c573c09b0..0660e6059a37f 100644 --- a/xbmc/windowing/X11/WinSystemX11GLES.cpp +++ b/xbmc/windowing/X11/WinSystemX11GLES.cpp @@ -27,6 +27,7 @@ #include "filesystem/SpecialProtocol.h" #include "settings/DisplaySettings.h" #include "settings/Settings.h" +#include "settings/DisplaySettings.h" #include "guilib/Texture.h" #include "windowing/X11/XRandR.h" #include diff --git a/xbmc/windowing/egl/WinSystemEGL.cpp b/xbmc/windowing/egl/WinSystemEGL.cpp index 85a5ef7c36ec2..245b439227d90 100644 --- a/xbmc/windowing/egl/WinSystemEGL.cpp +++ b/xbmc/windowing/egl/WinSystemEGL.cpp @@ -26,7 +26,7 @@ #include "guilib/GraphicContext.h" #include "settings/DisplaySettings.h" #include "settings/Settings.h" -#include "settings/GUISettings.h" +#include "settings/DisplaySettings.h" #include "utils/log.h" #include "EGLWrapper.h" #include "EGLQuirks.h" @@ -448,7 +448,7 @@ bool CWinSystemEGL::Support3D(int width, int height, uint32_t mode) const RESOLUTION_INFO &curr = CDisplaySettings::Get().GetResolutionInfo(g_graphicsContext.GetVideoResolution()); // if we are using automatic hdmi mode switching - if (g_guiSettings.GetInt("videoplayer.adjustrefreshrate") != ADJUST_REFRESHRATE_OFF) + if (CSettings::Get().GetInt("videoplayer.adjustrefreshrate") != ADJUST_REFRESHRATE_OFF) { int searchWidth = curr.iScreenWidth; int searchHeight = curr.iScreenHeight; diff --git a/xbmc/windowing/osx/WinSystemIOS.mm b/xbmc/windowing/osx/WinSystemIOS.mm index a2a4a665c73a4..1002e13229019 100644 --- a/xbmc/windowing/osx/WinSystemIOS.mm +++ b/xbmc/windowing/osx/WinSystemIOS.mm @@ -31,7 +31,6 @@ #include "utils/log.h" #include "filesystem/SpecialProtocol.h" #include "settings/DisplaySettings.h" -#include "settings/Settings.h" #include "guilib/GraphicContext.h" #include "guilib/Texture.h" #include diff --git a/xbmc/windowing/osx/WinSystemOSX.mm b/xbmc/windowing/osx/WinSystemOSX.mm index 1372a8c6be3e5..e45693cc4804c 100644 --- a/xbmc/windowing/osx/WinSystemOSX.mm +++ b/xbmc/windowing/osx/WinSystemOSX.mm @@ -30,7 +30,7 @@ #include "guilib/GUIWindowManager.h" #include "settings/DisplaySettings.h" #include "settings/Settings.h" -#include "settings/GUISettings.h" +#include "settings/DisplaySettings.h" #include "input/KeyboardStat.h" #include "threads/SingleLock.h" #include "utils/log.h" @@ -744,7 +744,7 @@ static void DisplayReconfigured(CGDirectDisplayID display, // send pre-configuration change now and do not // wait for switch videomode callback. This gives just // a little more advanced notice of the display pre-change. - if (g_guiSettings.GetInt("videoplayer.adjustrefreshrate") != ADJUST_REFRESHRATE_OFF) + if (CSettings::Get().GetInt("videoplayer.adjustrefreshrate") != ADJUST_REFRESHRATE_OFF) CheckDisplayChanging(kCGDisplayBeginConfigurationFlag); // switch videomode @@ -780,7 +780,7 @@ static void DisplayReconfigured(CGDirectDisplayID display, last_window_screen = [[last_view window] screen]; last_window_origin = [[last_view window] frame].origin; - if (g_guiSettings.GetBool("videoscreen.fakefullscreen")) + if (CSettings::Get().GetBool("videoscreen.fakefullscreen")) { // This is Cocca Windowed FullScreen Mode // Get the screen rect of our current display @@ -888,7 +888,7 @@ static void DisplayReconfigured(CGDirectDisplayID display, if (GetDisplayID(res.iScreen) == kCGDirectMainDisplay) SetMenuBarVisible(true); - if (g_guiSettings.GetBool("videoscreen.fakefullscreen")) + if (CSettings::Get().GetBool("videoscreen.fakefullscreen")) { // restore the windowed window level [[last_view window] setLevel:NSNormalWindowLevel]; diff --git a/xbmc/windowing/windows/WinEventsWin32.cpp b/xbmc/windowing/windows/WinEventsWin32.cpp index 471bb9bf2ab01..e1d663a8c88dd 100644 --- a/xbmc/windowing/windows/WinEventsWin32.cpp +++ b/xbmc/windowing/windows/WinEventsWin32.cpp @@ -43,8 +43,8 @@ #include "guilib/GUIControl.h" // for EVENT_RESULT #include "powermanagement/windows/Win32PowerSyscall.h" #include "Shlobj.h" -#include "settings/Settings.h" #include "settings/AdvancedSettings.h" +#include "settings/Settings.h" #include "peripherals/Peripherals.h" #include "utils/JobManager.h" #include "network/Zeroconf.h" @@ -487,7 +487,7 @@ LRESULT CALLBACK CWinEventsWin32::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, L case SC_MONITORPOWER: if (g_application.IsPlaying() || g_application.IsPaused()) return 0; - else if(g_guiSettings.GetInt("powermanagement.displaysoff") == 0) + else if(CSettings::Get().GetInt("powermanagement.displaysoff") == 0) return 0; break; case SC_SCREENSAVE: diff --git a/xbmc/windowing/windows/WinSystemWin32.cpp b/xbmc/windowing/windows/WinSystemWin32.cpp index 9cc9b23bc0500..8f5c46b495803 100644 --- a/xbmc/windowing/windows/WinSystemWin32.cpp +++ b/xbmc/windowing/windows/WinSystemWin32.cpp @@ -22,9 +22,9 @@ #include "WinEventsWin32.h" #include "resource.h" #include "guilib/gui3d.h" -#include "settings/DisplaySettings.h" -#include "settings/GUISettings.h" #include "settings/AdvancedSettings.h" +#include "settings/DisplaySettings.h" +#include "settings/Settings.h" #include "utils/log.h" #ifdef _WIN32 @@ -257,7 +257,7 @@ bool CWinSystemWin32::SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool { m_IsAlteringWindow = true; - CLog::Log(LOGDEBUG, "%s (%s) on screen %d with size %dx%d, refresh %f%s", __FUNCTION__, !fullScreen ? "windowed" : (g_guiSettings.GetBool("videoscreen.fakefullscreen") ? "windowed fullscreen" : "true fullscreen"), res.iScreen, res.iWidth, res.iHeight, res.fRefreshRate, (res.dwFlags & D3DPRESENTFLAG_INTERLACED) ? "i" : ""); + CLog::Log(LOGDEBUG, "%s (%s) on screen %d with size %dx%d, refresh %f%s", __FUNCTION__, !fullScreen ? "windowed" : (CSettings::Get().GetBool("videoscreen.fakefullscreen") ? "windowed fullscreen" : "true fullscreen"), res.iScreen, res.iWidth, res.iHeight, res.fRefreshRate, (res.dwFlags & D3DPRESENTFLAG_INTERLACED) ? "i" : ""); bool forceResize = false; @@ -284,7 +284,7 @@ bool CWinSystemWin32::SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool m_nHeight = res.iHeight; m_bBlankOtherDisplay = blankOtherDisplays; - if (fullScreen && g_guiSettings.GetBool("videoscreen.fakefullscreen")) + if (fullScreen && CSettings::Get().GetBool("videoscreen.fakefullscreen")) ChangeResolution(res); ResizeInternal(forceResize); diff --git a/xbmc/windowing/windows/WinSystemWin32DX.cpp b/xbmc/windowing/windows/WinSystemWin32DX.cpp index 4bcff0716f14e..f76763aeeda7b 100644 --- a/xbmc/windowing/windows/WinSystemWin32DX.cpp +++ b/xbmc/windowing/windows/WinSystemWin32DX.cpp @@ -20,7 +20,7 @@ #include "WinSystemWin32DX.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "guilib/gui3d.h" #ifdef HAS_DX @@ -38,7 +38,7 @@ CWinSystemWin32DX::~CWinSystemWin32DX() bool CWinSystemWin32DX::UseWindowedDX(bool fullScreen) { - return (g_guiSettings.GetBool("videoscreen.fakefullscreen") || !fullScreen); + return (CSettings::Get().GetBool("videoscreen.fakefullscreen") || !fullScreen); } bool CWinSystemWin32DX::CreateNewWindow(CStdString name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction) diff --git a/xbmc/windowing/windows/WinSystemWin32GL.cpp b/xbmc/windowing/windows/WinSystemWin32GL.cpp index d5346309a486d..19028fdf254da 100644 --- a/xbmc/windowing/windows/WinSystemWin32GL.cpp +++ b/xbmc/windowing/windows/WinSystemWin32GL.cpp @@ -26,7 +26,7 @@ */ #include "WinSystemWin32GL.h" #include "WIN32Util.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "guilib/gui3d.h" #ifdef HAS_GL @@ -83,7 +83,7 @@ bool CWinSystemWin32GL::InitRenderSystem() CWIN32Util::CheckGLVersion(); - g_guiSettings.SetBool("videoscreen.fakefullscreen", true); + CSettings::Get().SetBool("videoscreen.fakefullscreen", true); return true; } diff --git a/xbmc/windows/GUIMediaWindow.cpp b/xbmc/windows/GUIMediaWindow.cpp index 4fb5ef286ca19..ec25e1f8e1568 100644 --- a/xbmc/windows/GUIMediaWindow.cpp +++ b/xbmc/windows/GUIMediaWindow.cpp @@ -40,7 +40,7 @@ #include "dialogs/GUIDialogProgress.h" #include "profiles/ProfilesManager.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "URL.h" #include "dialogs/GUIDialogSmartPlaylistEditor.h" @@ -597,7 +597,7 @@ void CGUIMediaWindow::SortItems(CFileItemList &items) SortDescription sorting; sorting.sortBy = sortBy; sorting.sortOrder = items.GetProperty(PROPERTY_SORT_ASCENDING).asBoolean() ? SortOrderAscending : SortOrderDescending; - sorting.sortAttributes = g_guiSettings.GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone; + sorting.sortAttributes = CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone; // if the sort order is descending, we need to switch the original sort order, as we assume // in CGUIViewState::AddPlaylistOrder that SORT_METHOD_PLAYLIST_ORDER is ascending. @@ -1090,8 +1090,8 @@ bool CGUIMediaWindow::OnClick(int iItem) } // If karaoke song is being played AND popup autoselector is enabled, the playlist should not be added - bool do_not_add_karaoke = g_guiSettings.GetBool("karaoke.enabled") && - g_guiSettings.GetBool("karaoke.autopopupselector") && pItem->IsKaraoke(); + bool do_not_add_karaoke = CSettings::Get().GetBool("karaoke.enabled") && + CSettings::Get().GetBool("karaoke.autopopupselector") && pItem->IsKaraoke(); bool autoplay = m_guiState.get() && m_guiState->AutoPlayNextItem(); if (m_vecItems->IsPlugin()) diff --git a/xbmc/windows/GUIWindowFileManager.cpp b/xbmc/windows/GUIWindowFileManager.cpp index b750e9ce99224..df5e7da368983 100644 --- a/xbmc/windows/GUIWindowFileManager.cpp +++ b/xbmc/windows/GUIWindowFileManager.cpp @@ -47,10 +47,9 @@ #include "playlists/PlayList.h" #include "utils/AsyncFileCopy.h" #include "storage/MediaManager.h" -#include "settings/Settings.h" #include "settings/AdvancedSettings.h" -#include "settings/GUISettings.h" #include "settings/MediaSourceSettings.h" +#include "settings/Settings.h" #include "input/MouseStat.h" #include "guilib/LocalizeStrings.h" #include "utils/StringUtils.h" @@ -367,37 +366,6 @@ void CGUIWindowFileManager::ClearFileItems(int iList) void CGUIWindowFileManager::UpdateButtons() { - - /* - // Update sorting control - bool bSortOrder=false; - if ( m_bViewSource ) - { - if (m_strSourceDirectory.IsEmpty()) - bSortOrder=g_settings.m_bMyFilesSourceRootSortOrder; - else - bSortOrder=g_settings.m_bMyFilesSourceSortOrder; - } - else - { - if (m_strDestDirectory.IsEmpty()) - bSortOrder=g_settings.m_bMyFilesDestRootSortOrder; - else - bSortOrder=g_settings.m_bMyFilesDestSortOrder; - } - - if (bSortOrder) - { - CGUIMessage msg(GUI_MSG_DESELECTED,GetID(), CONTROL_BTNSORTASC); - g_windowManager.SendMessage(msg); - } - else - { - CGUIMessage msg(GUI_MSG_SELECTED,GetID(), CONTROL_BTNSORTASC); - g_windowManager.SendMessage(msg); - } - - */ // update our current directory labels CStdString strDir = CURL(m_Directory[0]->GetPath()).GetWithoutUserDetails(); if (strDir.IsEmpty()) @@ -490,7 +458,7 @@ bool CGUIWindowFileManager::Update(int iList, const CStdString &strDirectory) CStdString strParentPath; URIUtils::GetParentPath(strDirectory, strParentPath); - if (strDirectory.IsEmpty() && (m_vecItems[iList]->Size() == 0 || g_guiSettings.GetBool("filelists.showaddsourcebuttons"))) + if (strDirectory.IsEmpty() && (m_vecItems[iList]->Size() == 0 || CSettings::Get().GetBool("filelists.showaddsourcebuttons"))) { // add 'add source button' CStdString strLabel = g_localizeStrings.Get(1026); CFileItemPtr pItem(new CFileItem(strLabel)); @@ -502,7 +470,7 @@ bool CGUIWindowFileManager::Update(int iList, const CStdString &strDirectory) pItem->SetSpecialSort(SortSpecialOnBottom); m_vecItems[iList]->Add(pItem); } - else if (items.IsEmpty() || g_guiSettings.GetBool("filelists.showparentdiritems")) + else if (items.IsEmpty() || CSettings::Get().GetBool("filelists.showparentdiritems")) { CFileItemPtr pItem(new CFileItem("..")); pItem->SetPath(m_rootDir.IsSource(strDirectory) ? "" : strParentPath); diff --git a/xbmc/windows/GUIWindowLoginScreen.cpp b/xbmc/windows/GUIWindowLoginScreen.cpp index 699b5959aeacf..d30124ba8d622 100644 --- a/xbmc/windows/GUIWindowLoginScreen.cpp +++ b/xbmc/windows/GUIWindowLoginScreen.cpp @@ -42,7 +42,7 @@ #include "GUIUserMessages.h" #include "guilib/GUIWindowManager.h" #include "dialogs/GUIDialogOK.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "FileItem.h" #include "guilib/Key.h" #include "guilib/LocalizeStrings.h" @@ -234,7 +234,7 @@ bool CGUIWindowLoginScreen::OnPopupMenu(int iItem) if (choice == 3) { if (g_passwordManager.CheckLock(CProfilesManager::Get().GetMasterProfile().getLockMode(),CProfilesManager::Get().GetMasterProfile().getLockCode(),20075)) - g_passwordManager.iMasterLockRetriesLeft = g_guiSettings.GetInt("masterlock.maxretries"); + g_passwordManager.iMasterLockRetriesLeft = CSettings::Get().GetInt("masterlock.maxretries"); else // be inconvenient CApplicationMessenger::Get().Shutdown(); diff --git a/xbmc/windows/GUIWindowScreensaver.cpp b/xbmc/windows/GUIWindowScreensaver.cpp index 0e63802586e75..fc790e3263da9 100644 --- a/xbmc/windows/GUIWindowScreensaver.cpp +++ b/xbmc/windows/GUIWindowScreensaver.cpp @@ -23,7 +23,7 @@ #include "addons/AddonManager.h" #include "Application.h" #include "GUIPassword.h" -#include "settings/GUISettings.h" +#include "settings/Settings.h" #include "GUIUserMessages.h" #include "guilib/GUIWindowManager.h" #include "threads/SingleLock.h" @@ -139,7 +139,7 @@ bool CGUIWindowScreensaver::OnMessage(CGUIMessage& message) m_addon.reset(); // Setup new screensaver instance AddonPtr addon; - if (!CAddonMgr::Get().GetAddon(g_guiSettings.GetString("screensaver.mode"), addon, ADDON_SCREENSAVER)) + if (!CAddonMgr::Get().GetAddon(CSettings::Get().GetString("screensaver.mode"), addon, ADDON_SCREENSAVER)) return false; m_addon = boost::dynamic_pointer_cast(addon); diff --git a/xbmc/windows/GUIWindowWeather.cpp b/xbmc/windows/GUIWindowWeather.cpp index 925031e718aac..c67d45a5a947d 100644 --- a/xbmc/windows/GUIWindowWeather.cpp +++ b/xbmc/windows/GUIWindowWeather.cpp @@ -24,7 +24,6 @@ #include "GUIWindowWeather.h" #include "guilib/GUIImage.h" #include "utils/Weather.h" -#include "settings/GUISettings.h" #include "guilib/GUIWindowManager.h" #include "utils/URIUtils.h" #ifdef HAS_PYTHON