/xbmc/settings/GUIWindowSettingsCategory.cpp
C++ | 2836 lines | 2518 code | 199 blank | 119 comment | 804 complexity | 8c98e4602011a2a06db116b9e7036ecb MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0
Large files files are truncated, but you can click here to view the full file
- /*
- * Copyright (C) 2005-2008 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, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
- #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 "video/VideoDatabase.h"
- #include "ViewDatabase.h"
- #ifdef HAS_LCD
- #include "utils/LCDFactory.h"
- #endif
- #include "PlayListPlayer.h"
- #include "addons/Skin.h"
- #include "guilib/GUIAudioManager.h"
- #include "network/libscrobbler/lastfmscrobbler.h"
- #include "network/libscrobbler/librefmscrobbler.h"
- #include "GUIPassword.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 "dialogs/GUIDialogKaiToast.h"
- #include "addons/Visualisation.h"
- #include "addons/AddonManager.h"
- #include "addons/AddonInstaller.h"
- #include "storage/MediaManager.h"
- #include "network/Network.h"
- #include "guilib/GUIControlGroupList.h"
- #include "guilib/GUIWindowManager.h"
- #include "guilib/GUIFontManager.h"
- #include "cores/AudioEngine/AEFactory.h"
- #ifdef _LINUX
- #include "LinuxTimezone.h"
- #include <dlfcn.h>
- #ifdef HAS_HAL
- #include "HALManager.h"
- #endif
- #endif
- #if defined(TARGET_DARWIN_OSX)
- #include "XBMCHelper.h"
- #endif
- #include "network/GUIDialogAccessPoints.h"
- #include "filesystem/Directory.h"
- #include "FileItem.h"
- #include "guilib/GUIToggleButtonControl.h"
- #include "filesystem/SpecialProtocol.h"
- #include "network/Zeroconf.h"
- #include "peripherals/Peripherals.h"
- #include "peripherals/dialogs/GUIDialogPeripheralManager.h"
- #ifdef _WIN32
- #include "WIN32Util.h"
- #endif
- #include <map>
- #include "Settings.h"
- #include "AdvancedSettings.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/LocalizeStrings.h"
- #include "LangInfo.h"
- #include "utils/StringUtils.h"
- #include "utils/URIUtils.h"
- #include "utils/SystemInfo.h"
- #include "windowing/WindowingFactory.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
- using namespace std;
- using namespace XFILE;
- using namespace ADDON;
- using namespace PERIPHERALS;
- #define CONTROL_GROUP_BUTTONS 0
- #define CONTROL_GROUP_SETTINGS 1
- #define CONTROL_SETTINGS_LABEL 2
- #define CATEGORY_GROUP_ID 3
- #define SETTINGS_GROUP_ID 5
- #define CONTROL_DEFAULT_BUTTON 7
- #define CONTROL_DEFAULT_RADIOBUTTON 8
- #define CONTROL_DEFAULT_SPIN 9
- #define CONTROL_DEFAULT_CATEGORY_BUTTON 10
- #define CONTROL_DEFAULT_SEPARATOR 11
- #define CONTROL_DEFAULT_EDIT 12
- #define CONTROL_START_BUTTONS -100
- #define CONTROL_START_CONTROL -80
- CGUIWindowSettingsCategory::CGUIWindowSettingsCategory(void)
- : CGUIWindow(WINDOW_SETTINGS_MYPICTURES, "SettingsCategory.xml")
- {
- m_pOriginalSpin = NULL;
- m_pOriginalRadioButton = NULL;
- m_pOriginalButton = NULL;
- m_pOriginalCategoryButton = NULL;
- m_pOriginalImage = NULL;
- m_pOriginalEdit = NULL;
- // set the correct ID range...
- m_idRange = 8;
- m_iScreen = 0;
- m_strOldTrackFormat = "";
- m_strOldTrackFormatRight = "";
- m_returningFromSkinLoad = false;
- m_delayedSetting = NULL;
- }
- 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);
- }
- bool CGUIWindowSettingsCategory::OnMessage(CGUIMessage &message)
- {
- switch (message.GetMessage())
- {
- case GUI_MSG_CLICKED:
- {
- unsigned int iControl = message.GetSenderId();
- for (unsigned int i = 0; i < m_vecSettings.size(); i++)
- {
- if (m_vecSettings[i]->GetID() == (int)iControl)
- OnClick(m_vecSettings[i]);
- }
- }
- break;
- 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)
- {
- // changing section, check for updates and cancel any delayed changes
- m_delayedSetting = NULL;
- CheckForUpdates();
- if (m_vecSections[focusedControl-CONTROL_START_BUTTONS]->m_strCategory == "masterlock")
- {
- 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_iSection = focusedControl - CONTROL_START_BUTTONS;
- CreateSettings();
- }
- return true;
- }
- case GUI_MSG_LOAD_SKIN:
- {
- if (IsActive())
- m_returningFromSkinLoad = true;
- }
- break;
- case GUI_MSG_WINDOW_INIT:
- {
- m_delayedSetting = NULL;
- 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();
- }
- 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 = NULL;
- return true;
- }
- break;
- 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 = NULL;
- if (IsActive() && g_guiSettings.GetResolution() != g_graphicsContext.GetVideoResolution())
- {
- g_guiSettings.SetResolution(g_graphicsContext.GetVideoResolution());
- CreateSettings();
- }
- }
- }
- break;
- case GUI_MSG_WINDOW_DEINIT:
- {
- m_delayedSetting = NULL;
- CheckForUpdates();
- CGUIWindow::OnMessage(message);
- FreeControls();
- return true;
- }
- break;
- }
- return CGUIWindow::OnMessage(message);
- }
- void CGUIWindowSettingsCategory::SetupControls()
- {
- // 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);
- m_pOriginalButton = (CGUIButtonControl *)GetControl(CONTROL_DEFAULT_BUTTON);
- m_pOriginalImage = (CGUIImage *)GetControl(CONTROL_DEFAULT_SEPARATOR);
- if (!m_pOriginalCategoryButton || !m_pOriginalSpin || !m_pOriginalRadioButton || !m_pOriginalButton)
- return ;
- m_pOriginalEdit = (CGUIEditControl *)GetControl(CONTROL_DEFAULT_EDIT);
- if (!m_pOriginalEdit || m_pOriginalEdit->GetControlType() != CGUIControl::GUICONTROL_EDIT)
- {
- delete m_pOriginalEdit;
- m_pOriginalEdit = new CGUIEditControl(*m_pOriginalButton);
- }
- 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 ;
- // update the screen string
- SET_CONTROL_LABEL(CONTROL_SETTINGS_LABEL, pSettingsGroup->GetLabelID());
- // 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++)
- {
- if (m_vecSections[i]->m_labelID == 12360 && !g_settings.IsMasterUser())
- 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->SetVisible(true);
- pButton->AllocResources();
- group->AddControl(pButton);
- j++;
- }
- if (m_iSection < 0 || m_iSection >= (int)m_vecSections.size())
- m_iSection = 0;
- CreateSettings();
- // set focus correctly
- m_defaultControl = CONTROL_START_BUTTONS;
- }
- CGUIControl* CGUIWindowSettingsCategory::AddIntBasedSpinControl(CSetting *pSetting, float groupWidth, int &iControlID)
- {
- CSettingInt *pSettingInt = (CSettingInt*)pSetting;
- CGUISpinControlEx *pControl = (CGUISpinControlEx *)AddSetting(pSetting, groupWidth, iControlID);
- if (!pSettingInt->m_entries.empty())
- {
- for (map<int,int>::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());
- }
- return pControl;
- }
- void CGUIWindowSettingsCategory::CreateSettings()
- {
- FreeSettingsControls();
- CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(SETTINGS_GROUP_ID);
- if (!group)
- 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++)
- {
- CSetting *pSetting = settings[i];
- CStdString strSetting = pSetting->GetSetting();
- if (pSetting->GetType() == SETTINGS_TYPE_INT)
- {
- CGUISpinControlEx *pControl = (CGUISpinControlEx *)AddIntBasedSpinControl(pSetting, group->GetWidth(), iControlID);
- CSettingInt *pSettingInt = (CSettingInt*)pSetting;
- if (strSetting.Equals("videoplayer.pauseafterrefreshchange"))
- {
- pControl->AddLabel(g_localizeStrings.Get(13551), 0);
- 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, g_guiSettings.GetResolution());
- else if (strSetting.Equals("videoscreen.resolution"))
- FillInResolutions(strSetting, g_guiSettings.GetInt("videoscreen.screen"), g_guiSettings.GetResolution(), false);
- continue;
- }
- #ifdef HAS_WEB_SERVER
- else if (strSetting.Equals("services.webserverport"))
- {
- AddSetting(pSetting, group->GetWidth(), iControlID);
- CBaseSettingControl *control = GetSetting(pSetting->GetSetting());
- control->SetDelayed();
- continue;
- }
- #endif
- else if (strSetting.Equals("services.esport"))
- {
- #ifdef HAS_EVENT_SERVER
- AddSetting(pSetting, group->GetWidth(), iControlID);
- CBaseSettingControl *control = GetSetting(pSetting->GetSetting());
- control->SetDelayed();
- continue;
- #endif
- }
- else if (strSetting.Equals("network.httpproxyport"))
- {
- AddSetting(pSetting, group->GetWidth(), iControlID);
- CBaseSettingControl *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<CStdString> languages;
- languages.push_back(g_localizeStrings.Get(308));
- languages.push_back(g_localizeStrings.Get(309));
- vector<CStdString> 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<CStdString> 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<CStdString> 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, g_guiSettings.GetResolution(), 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++)
- {
- CBaseSettingControl *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(!g_settings.GetCurrentProfile().filesLocked() || g_passwordManager.bMasterUser);
- }
- else if (strSetting.Equals("filelists.showaddsourcebuttons"))
- {
- CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
- if (pControl) pControl->SetEnabled(g_settings.GetCurrentProfile().canWriteSources() || g_passwordManager.bMasterUser);
- }
- else if (strSetting.Equals("masterlock.startuplock"))
- {
- CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
- if (pControl) pControl->SetEnabled(g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE);
- }
- 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("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("audiooutput.guisoundmode"))
- {
- CAEFactory::SetSoundMode(g_guiSettings.GetInt("audiooutput.guisoundmode"));
- }
- else if (strSetting.Equals("musicplayer.crossfade"))
- {
- CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
- if (pControl) pControl->SetEnabled(g_guiSettings.GetString("audiooutput.audiodevice").find("wasapi:") == CStdString::npos);
- }
- else if (strSetting.Equals("musicplayer.crossfadealbumtracks"))
- {
- CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
- if (pControl) pControl->SetEnabled(g_guiSettings.GetInt("musicplayer.crossfade") > 0 &&
- g_guiSettings.GetString("audiooutput.audiodevice").find("wasapi:") == CStdString::npos);
- }
- #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"))
- {
- 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("scrobbler.lastfmusername") || strSetting.Equals("scrobbler.lastfmpass"))
- {
- CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(pSettingControl->GetID());
- if (pControl)
- pControl->SetEnabled(g_guiSettings.GetBool("scrobbler.lastfmsubmit") | g_guiSettings.GetBool("scrobbler.lastfmsubmitradio"));
- }
- else if (strSetting.Equals("scrobbler.librefmusername") || strSetting.Equals("scrobbler.librefmpass"))
- {
- CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(pSettingControl->GetID());
- if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("scrobbler.librefmsubmit"));
- }
- 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.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");
- }
- }
- #ifdef HAS_TIME_SERVER
- else if (strSetting.Equals("locale.timeserveraddress"))
- {
- CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
- if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("locale.timeserver"));
- }
- #endif
- 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("videoplayer.pauseafterrefreshchange"))
- {
- CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
- if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("videoplayer.adjustrefreshrate"));
- }
- 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);
- }
- }
- }
- void CGUIWindowSettingsCategory::OnClick(CBaseSettingControl *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();
- 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++)
- {
- CBaseSettingControl *pSettingControl = m_vecSettings[i];
- if (pSettingControl->NeedsUpdate())
- {
- OnSettingChanged(pSettingControl);
- pSettingControl->Reset();
- }
- }
- }
- void CGUIWindowSettingsCategory::OnSettingChanged(CBaseSettingControl *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"))
- {
- if (g_guiSettings.GetBool("debug.showloginfo"))
- {
- int level = std::max(g_advancedSettings.m_logLevelHint, LOG_LEVEL_DEBUG_FREEMEM);
- g_advancedSettings.m_logLevel = level;
- CLog::SetLogLevel(level);
- CLog::Log(LOGNOTICE, "Enabled debug logging due to GUI setting. Level %d.", level);
- }
- else
- {
- int level = std::min(g_advancedSettings.m_logLevelHint, LOG_LEVEL_DEBUG/*LOG_LEVEL_NORMAL*/);
- CLog::Log(LOGNOTICE, "Disabled debug logging due to GUI setting. Level %d.", level);
- g_advancedSettings.m_logLevel = level;
- CLog::SetLogLevel(level);
- }
- }
- /*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(g_settings.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(g_settings.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.Equals("scrobbler.lastfmsubmit") || strSetting.Equals("scrobbler.lastfmsubmitradio") || strSetting.Equals("scrobbler.lastfmusername") || strSetting.Equals("scrobbler.lastfmpass"))
- {
- CStdString strPassword=g_guiSettings.GetString("scrobbler.lastfmpass");
- CStdString strUserName=g_guiSettings.GetString("scrobbler.lastfmusername");
- if ((g_guiSettings.GetBool("scrobbler.lastfmsubmit") ||
- g_guiSettings.GetBool("scrobbler.lastfmsubmitradio")) &&
- !strUserName.IsEmpty() && !strPassword.IsEmpty())
- {
- CLastfmScrobbler::GetInstance()->Init();
- }
- else
- {
- CLastfmScrobbler::GetInstance()->Term();
- }
- }
- else if (strSetting.Equals("scrobbler.librefmsubmit") || strSetting.Equals("scrobbler.librefmsubmitradio") || strSetting.Equals("scrobbler.librefmusername") || strSetting.Equals("scrobbler.librefmpass"))
- {
- CStdString strPassword=g_guiSettings.GetString("scrobbler.librefmpass");
- CStdString strUserName=g_guiSettings.GetString("scrobbler.librefmusername");
- if ((g_guiSettings.GetBool("scrobbler.librefmsubmit") ||
- g_guiSettings.GetBool("scrobbler.librefmsubmitradio")) &&
- !strUserName.IsEmpty() && !strPassword.IsEmpty())
- {
- CLibrefmScrobbler::GetInstance()->Init();
- }
- else
- {
- CLibrefmScrobbler::GetInstance()->Term();
- }
- }
- else if (strSetting.Left(22).Equals("MusicPlayer.ReplayGain"))
- { // Update our replaygain settings
- g_guiSettings.m_replayGain.iType = g_guiSettings.GetInt("musicplayer.replaygaintype");
- g_guiSettings.m_replayGain.iPreAmp = g_guiSettings.GetInt("musicplayer.replaygainpreamp");
- g_guiSettings.m_replayGain.iNoGainPreAmp = g_guiSettings.GetInt("musicplayer.replaygainnogainpreamp");
- g_guiSettings.m_replayGain.bAvoidClipping = g_guiSettings.GetBool("musicplayer.replaygainavoidclipping");
- }
- #ifdef HAS_LCD
- else if (strSetting.Equals("videoscreen.haslcd"))
- {
- g_lcd->Stop();
- CLCDFactory factory;
- delete g_lcd;
- g_lcd = factory.Create();
- g_lcd->Initialize();
- }
- #endif
- #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(pS…
Large files files are truncated, but you can click here to view the full file