2 * Copyright (C) 2005-2008 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
23 #include "GUIUserMessages.h"
24 #include "GUIWindowSettingsCategory.h"
25 #include "Application.h"
26 #include "interfaces/Builtins.h"
27 #include "input/KeyboardLayoutConfiguration.h"
28 #include "filesystem/Directory.h"
30 #include "guilib/GUISpinControlEx.h"
31 #include "guilib/GUIRadioButtonControl.h"
32 #include "guilib/GUIEditControl.h"
33 #include "guilib/GUIImage.h"
34 #include "utils/Weather.h"
35 #include "music/MusicDatabase.h"
36 #include "video/VideoDatabase.h"
37 #include "ViewDatabase.h"
39 #include "utils/LCDFactory.h"
41 #include "PlayListPlayer.h"
42 #include "addons/Skin.h"
43 #include "guilib/GUIAudioManager.h"
44 #include "guilib/AudioContext.h"
45 #include "network/libscrobbler/lastfmscrobbler.h"
46 #include "network/libscrobbler/librefmscrobbler.h"
47 #include "GUIPassword.h"
48 #include "dialogs/GUIDialogGamepad.h"
49 #include "dialogs/GUIDialogNumeric.h"
50 #include "dialogs/GUIDialogFileBrowser.h"
51 #include "addons/GUIDialogAddonSettings.h"
52 #include "addons/GUIWindowAddonBrowser.h"
53 #include "dialogs/GUIDialogContextMenu.h"
54 #include "dialogs/GUIDialogKeyboard.h"
55 #include "dialogs/GUIDialogYesNo.h"
56 #include "dialogs/GUIDialogOK.h"
57 #include "dialogs/GUIDialogProgress.h"
58 #include "dialogs/GUIDialogKaiToast.h"
59 #include "addons/Visualisation.h"
60 #include "addons/AddonManager.h"
61 #include "addons/AddonInstaller.h"
62 #include "storage/MediaManager.h"
63 #include "network/Network.h"
64 #include "guilib/GUIControlGroupList.h"
65 #include "guilib/GUIWindowManager.h"
66 #include "guilib/GUIFontManager.h"
68 #include "LinuxTimezone.h"
70 #include "cores/AudioRenderers/AudioRendererFactory.h"
72 #include "cores/AudioRenderers/ALSADirectSound.h"
75 #include "HALManager.h"
78 #if defined(__APPLE__)
80 #include "IOSCoreAudio.h"
82 #include "CoreAudio.h"
83 #include "XBMCHelper.h"
86 #include "network/GUIDialogAccessPoints.h"
87 #include "filesystem/Directory.h"
90 #include "guilib/GUIToggleButtonControl.h"
91 #include "filesystem/SpecialProtocol.h"
93 #include "network/Zeroconf.h"
94 #include "peripherals/Peripherals.h"
95 #include "peripherals/dialogs/GUIDialogPeripheralManager.h"
98 #include "WIN32Util.h"
99 #include "cores/AudioRenderers/AudioRendererFactory.h"
102 #include "Settings.h"
103 #include "AdvancedSettings.h"
104 #include "input/MouseStat.h"
105 #include "guilib/LocalizeStrings.h"
106 #include "LangInfo.h"
107 #include "utils/StringUtils.h"
108 #include "utils/URIUtils.h"
109 #include "windowing/WindowingFactory.h"
111 #if defined(HAVE_LIBCRYSTALHD)
112 #include "cores/dvdplayer/DVDCodecs/Video/CrystalHD.h"
115 #if defined(HAS_AIRPLAY)
116 #include "network/AirPlayServer.h"
120 using namespace XFILE;
121 using namespace ADDON;
122 using namespace PERIPHERALS;
124 #define CONTROL_GROUP_BUTTONS 0
125 #define CONTROL_GROUP_SETTINGS 1
126 #define CONTROL_SETTINGS_LABEL 2
127 #define CATEGORY_GROUP_ID 3
128 #define SETTINGS_GROUP_ID 5
129 #define CONTROL_DEFAULT_BUTTON 7
130 #define CONTROL_DEFAULT_RADIOBUTTON 8
131 #define CONTROL_DEFAULT_SPIN 9
132 #define CONTROL_DEFAULT_CATEGORY_BUTTON 10
133 #define CONTROL_DEFAULT_SEPARATOR 11
134 #define CONTROL_DEFAULT_EDIT 12
135 #define CONTROL_START_BUTTONS -100
136 #define CONTROL_START_CONTROL -80
138 CGUIWindowSettingsCategory::CGUIWindowSettingsCategory(void)
139 : CGUIWindow(WINDOW_SETTINGS_MYPICTURES, "SettingsCategory.xml")
141 m_pOriginalSpin = NULL;
142 m_pOriginalRadioButton = NULL;
143 m_pOriginalButton = NULL;
144 m_pOriginalCategoryButton = NULL;
145 m_pOriginalImage = NULL;
146 m_pOriginalEdit = NULL;
147 // set the correct ID range...
150 // set the network settings so that we don't reset them unnecessarily
151 m_iNetworkAssignment = -1;
152 m_strErrorMessage = "";
153 m_strOldTrackFormat = "";
154 m_strOldTrackFormatRight = "";
155 m_returningFromSkinLoad = false;
156 m_delayedSetting = NULL;
159 CGUIWindowSettingsCategory::~CGUIWindowSettingsCategory(void)
162 delete m_pOriginalEdit;
165 bool CGUIWindowSettingsCategory::OnBack(int actionID)
168 m_lastControlID = 0; // don't save the control as we go to a different window each time
169 return CGUIWindow::OnBack(actionID);
172 bool CGUIWindowSettingsCategory::OnMessage(CGUIMessage &message)
174 switch (message.GetMessage())
176 case GUI_MSG_CLICKED:
178 unsigned int iControl = message.GetSenderId();
179 /* if (iControl >= CONTROL_START_BUTTONS && iControl < CONTROL_START_BUTTONS + m_vecSections.size())
181 // change the setting...
182 m_iSection = iControl-CONTROL_START_BUTTONS;
183 CheckNetworkSettings();
187 for (unsigned int i = 0; i < m_vecSettings.size(); i++)
189 if (m_vecSettings[i]->GetID() == (int)iControl)
190 OnClick(m_vecSettings[i]);
194 case GUI_MSG_FOCUSED:
196 CGUIWindow::OnMessage(message);
197 int focusedControl = GetFocusedControlID();
198 if (focusedControl >= CONTROL_START_BUTTONS && focusedControl < (int)(CONTROL_START_BUTTONS + m_vecSections.size()) &&
199 focusedControl - CONTROL_START_BUTTONS != m_iSection && !m_returningFromSkinLoad)
201 // changing section, check for updates and cancel any delayed changes
202 m_delayedSetting = NULL;
205 if (m_vecSections[focusedControl-CONTROL_START_BUTTONS]->m_strCategory == "masterlock")
207 if (!g_passwordManager.IsMasterLockUnlocked(true))
208 { // unable to go to this category - focus the previous one
209 SET_CONTROL_FOCUS(CONTROL_START_BUTTONS + m_iSection, 0);
213 m_iSection = focusedControl - CONTROL_START_BUTTONS;
214 CheckNetworkSettings();
220 case GUI_MSG_LOAD_SKIN:
223 m_returningFromSkinLoad = true;
226 case GUI_MSG_WINDOW_INIT:
228 m_delayedSetting = NULL;
229 if (message.GetParam1() != WINDOW_INVALID && !m_returningFromSkinLoad)
230 { // coming to this window first time (ie not returning back from some other window)
231 // so we reset our section and control states
233 ResetControlStates();
235 m_iScreen = (int)message.GetParam2() - (int)CGUIWindow::GetID();
236 CGUIWindow::OnMessage(message);
237 m_returningFromSkinLoad = false;
241 case GUI_MSG_UPDATE_ITEM:
242 if (m_delayedSetting)
244 OnSettingChanged(m_delayedSetting);
245 m_delayedSetting = NULL;
249 case GUI_MSG_NOTIFY_ALL:
251 if (message.GetParam1() == GUI_MSG_WINDOW_RESIZE)
253 // Cancel delayed setting - it's only used for res changing anyway
254 m_delayedSetting = NULL;
255 if (IsActive() && g_guiSettings.GetResolution() != g_graphicsContext.GetVideoResolution())
257 g_guiSettings.SetResolution(g_graphicsContext.GetVideoResolution());
263 case GUI_MSG_WINDOW_DEINIT:
265 m_delayedSetting = NULL;
268 CheckNetworkSettings();
269 CGUIWindow::OnMessage(message);
275 return CGUIWindow::OnMessage(message);
278 void CGUIWindowSettingsCategory::SetupControls()
280 // cleanup first, if necessary
282 m_pOriginalSpin = (CGUISpinControlEx*)GetControl(CONTROL_DEFAULT_SPIN);
283 m_pOriginalRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_DEFAULT_RADIOBUTTON);
284 m_pOriginalCategoryButton = (CGUIButtonControl *)GetControl(CONTROL_DEFAULT_CATEGORY_BUTTON);
285 m_pOriginalButton = (CGUIButtonControl *)GetControl(CONTROL_DEFAULT_BUTTON);
286 m_pOriginalImage = (CGUIImage *)GetControl(CONTROL_DEFAULT_SEPARATOR);
287 if (!m_pOriginalCategoryButton || !m_pOriginalSpin || !m_pOriginalRadioButton || !m_pOriginalButton)
289 m_pOriginalEdit = (CGUIEditControl *)GetControl(CONTROL_DEFAULT_EDIT);
290 if (!m_pOriginalEdit || m_pOriginalEdit->GetControlType() != CGUIControl::GUICONTROL_EDIT)
292 delete m_pOriginalEdit;
293 m_pOriginalEdit = new CGUIEditControl(*m_pOriginalButton);
295 m_pOriginalSpin->SetVisible(false);
296 m_pOriginalRadioButton->SetVisible(false);
297 m_pOriginalButton->SetVisible(false);
298 m_pOriginalCategoryButton->SetVisible(false);
299 m_pOriginalEdit->SetVisible(false);
300 if (m_pOriginalImage) m_pOriginalImage->SetVisible(false);
301 // setup our control groups...
302 CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(CATEGORY_GROUP_ID);
305 // get a list of different sections
306 CSettingsGroup *pSettingsGroup = g_guiSettings.GetGroup(m_iScreen);
307 if (!pSettingsGroup) return ;
308 // update the screen string
309 SET_CONTROL_LABEL(CONTROL_SETTINGS_LABEL, pSettingsGroup->GetLabelID());
310 // get the categories we need
311 pSettingsGroup->GetCategories(m_vecSections);
312 // run through and create our buttons...
314 for (unsigned int i = 0; i < m_vecSections.size(); i++)
316 if (m_vecSections[i]->m_labelID == 12360 && !g_settings.IsMasterUser())
318 CGUIButtonControl *pButton = NULL;
319 if (m_pOriginalCategoryButton->GetControlType() == CGUIControl::GUICONTROL_TOGGLEBUTTON)
320 pButton = new CGUIToggleButtonControl(*(CGUIToggleButtonControl *)m_pOriginalCategoryButton);
322 pButton = new CGUIButtonControl(*m_pOriginalCategoryButton);
323 pButton->SetLabel(g_localizeStrings.Get(m_vecSections[i]->m_labelID));
324 pButton->SetID(CONTROL_START_BUTTONS + j);
325 pButton->SetVisible(true);
326 pButton->AllocResources();
327 group->AddControl(pButton);
330 if (m_iSection < 0 || m_iSection >= (int)m_vecSections.size())
333 // set focus correctly
334 m_defaultControl = CONTROL_START_BUTTONS;
337 CGUIControl* CGUIWindowSettingsCategory::AddIntBasedSpinControl(CSetting *pSetting, float groupWidth, int &iControlID)
339 CSettingInt *pSettingInt = (CSettingInt*)pSetting;
340 CGUISpinControlEx *pControl = (CGUISpinControlEx *)AddSetting(pSetting, groupWidth, iControlID);
341 if (!pSettingInt->m_entries.empty())
343 for (map<int,int>::iterator it=pSettingInt->m_entries.begin(); it != pSettingInt->m_entries.end();++it)
344 pControl->AddLabel(g_localizeStrings.Get(it->first), it->second);
345 pControl->SetValue(pSettingInt->GetData());
350 void CGUIWindowSettingsCategory::CreateSettings()
352 FreeSettingsControls();
354 CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(SETTINGS_GROUP_ID);
357 vecSettings settings;
358 g_guiSettings.GetSettingsGroup(m_vecSections[m_iSection]->m_strCategory, settings);
359 int iControlID = CONTROL_START_CONTROL;
360 for (unsigned int i = 0; i < settings.size(); i++)
362 CSetting *pSetting = settings[i];
363 CStdString strSetting = pSetting->GetSetting();
364 if (pSetting->GetType() == SETTINGS_TYPE_INT)
366 CGUISpinControlEx *pControl = (CGUISpinControlEx *)AddIntBasedSpinControl(pSetting, group->GetWidth(), iControlID);
367 CSettingInt *pSettingInt = (CSettingInt*)pSetting;
368 if (strSetting.Equals("videoplayer.pauseafterrefreshchange"))
370 pControl->AddLabel(g_localizeStrings.Get(13551), 0);
372 for (int i = 1; i <= MAXREFRESHCHANGEDELAY; i++)
374 CStdString delayText;
375 delayText.Format(g_localizeStrings.Get(13553).c_str(), (double)i / 10.0);
376 pControl->AddLabel(delayText, i);
378 pControl->SetValue(pSettingInt->GetData());
380 else if (strSetting.Equals("subtitles.color"))
382 for (int i = SUBTITLE_COLOR_START; i <= SUBTITLE_COLOR_END; i++)
383 pControl->AddLabel(g_localizeStrings.Get(760 + i), i);
384 pControl->SetValue(pSettingInt->GetData());
386 else if (strSetting.Equals("lookandfeel.startupwindow"))
387 FillInStartupWindow(pSetting);
388 else if (strSetting.Equals("subtitles.height") || strSetting.Equals("karaoke.fontheight") )
389 FillInSubtitleHeights(pSetting, pControl);
390 else if (strSetting.Equals("videoscreen.screen"))
391 FillInScreens(strSetting, g_guiSettings.GetResolution());
392 else if (strSetting.Equals("videoscreen.resolution"))
393 FillInResolutions(strSetting, g_guiSettings.GetInt("videoscreen.screen"), g_guiSettings.GetResolution(), false);
396 #ifdef HAS_WEB_SERVER
397 else if (strSetting.Equals("services.webserverport"))
399 AddSetting(pSetting, group->GetWidth(), iControlID);
400 CBaseSettingControl *control = GetSetting(pSetting->GetSetting());
401 control->SetDelayed();
405 else if (strSetting.Equals("services.esport"))
407 #ifdef HAS_EVENT_SERVER
408 AddSetting(pSetting, group->GetWidth(), iControlID);
409 CBaseSettingControl *control = GetSetting(pSetting->GetSetting());
410 control->SetDelayed();
414 else if (strSetting.Equals("network.httpproxyport"))
416 AddSetting(pSetting, group->GetWidth(), iControlID);
417 CBaseSettingControl *control = GetSetting(pSetting->GetSetting());
418 control->SetDelayed();
421 else if (strSetting.Equals("subtitles.font") || strSetting.Equals("karaoke.font") )
423 AddSetting(pSetting, group->GetWidth(), iControlID);
424 FillInSubtitleFonts(pSetting);
427 else if (strSetting.Equals("subtitles.charset") || strSetting.Equals("locale.charset") || strSetting.Equals("karaoke.charset"))
429 AddSetting(pSetting, group->GetWidth(), iControlID);
430 FillInCharSets(pSetting);
433 else if (strSetting.Equals("lookandfeel.font"))
435 AddSetting(pSetting, group->GetWidth(), iControlID);
436 FillInSkinFonts(pSetting);
439 else if (strSetting.Equals("lookandfeel.soundskin"))
441 AddSetting(pSetting, group->GetWidth(), iControlID);
442 FillInSoundSkins(pSetting);
445 else if (strSetting.Equals("locale.language"))
447 AddSetting(pSetting, group->GetWidth(), iControlID);
448 FillInLanguages(pSetting);
452 else if (strSetting.Equals("locale.timezonecountry"))
454 CStdString myTimezoneCountry = g_guiSettings.GetString("locale.timezonecountry");
455 int myTimezeoneCountryIndex = 0;
457 CGUISpinControlEx *pControl = (CGUISpinControlEx *)AddSetting(pSetting, group->GetWidth(), iControlID);
458 vector<CStdString> countries = g_timezone.GetCounties();
459 for (unsigned int i=0; i < countries.size(); i++)
461 if (countries[i] == myTimezoneCountry)
462 myTimezeoneCountryIndex = i;
463 pControl->AddLabel(countries[i], i);
465 pControl->SetValue(myTimezeoneCountryIndex);
468 else if (strSetting.Equals("locale.timezone"))
470 CStdString myTimezoneCountry = g_guiSettings.GetString("locale.timezonecountry");
471 CStdString myTimezone = g_guiSettings.GetString("locale.timezone");
472 int myTimezoneIndex = 0;
474 CGUISpinControlEx *pControl = (CGUISpinControlEx *)AddSetting(pSetting, group->GetWidth(), iControlID);
476 vector<CStdString> timezones = g_timezone.GetTimezonesByCountry(myTimezoneCountry);
477 for (unsigned int i=0; i < timezones.size(); i++)
479 if (timezones[i] == myTimezone)
481 pControl->AddLabel(timezones[i], i);
483 pControl->SetValue(myTimezoneIndex);
487 else if (strSetting.Equals("videoscreen.screenmode"))
489 AddSetting(pSetting, group->GetWidth(), iControlID);
490 FillInRefreshRates(strSetting, g_guiSettings.GetResolution(), false);
493 else if (strSetting.Equals("lookandfeel.skintheme"))
495 AddSetting(pSetting, group->GetWidth(), iControlID);
496 FillInSkinThemes(pSetting);
499 else if (strSetting.Equals("lookandfeel.skincolors"))
501 AddSetting(pSetting, group->GetWidth(), iControlID);
502 FillInSkinColors(pSetting);
506 FIXME: setting is hidden in GUI because not supported properly.
507 else if (strSetting.Equals("videoplayer.displayresolution") || strSetting.Equals("pictures.displayresolution"))
509 FillInResolutions(pSetting);
512 else if (strSetting.Equals("locale.country"))
514 AddSetting(pSetting, group->GetWidth(), iControlID);
515 FillInRegions(pSetting);
518 else if (strSetting.Equals("network.interface"))
520 FillInNetworkInterfaces(pSetting, group->GetWidth(), iControlID);
523 else if (strSetting.Equals("audiooutput.audiodevice"))
525 AddSetting(pSetting, group->GetWidth(), iControlID);
526 FillInAudioDevices(pSetting);
529 else if (strSetting.Equals("audiooutput.passthroughdevice"))
531 AddSetting(pSetting, group->GetWidth(), iControlID);
532 FillInAudioDevices(pSetting,true);
535 AddSetting(pSetting, group->GetWidth(), iControlID);
538 if (m_vecSections[m_iSection]->m_strCategory == "network")
539 NetworkInterfaceChanged();
541 // update our settings (turns controls on/off as appropriate)
545 void CGUIWindowSettingsCategory::UpdateSettings()
547 for (unsigned int i = 0; i < m_vecSettings.size(); i++)
549 CBaseSettingControl *pSettingControl = m_vecSettings[i];
550 pSettingControl->Update();
551 CStdString strSetting = pSettingControl->GetSetting()->GetSetting();
553 if (strSetting.Equals("videoplayer.vdpauUpscalingLevel"))
555 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
558 pControl->SetEnabled(true);
563 if (strSetting.Equals("videoscreen.resolution"))
565 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
567 pControl->SetEnabled(g_guiSettings.GetInt("videoscreen.screen") != DM_WINDOWED);
569 else if (strSetting.Equals("videoscreen.screenmode"))
571 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
573 pControl->SetEnabled(g_guiSettings.GetInt("videoscreen.screen") != DM_WINDOWED);
575 else if (strSetting.Equals("videoscreen.fakefullscreen"))
577 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
579 pControl->SetEnabled(g_guiSettings.GetInt("videoscreen.screen") != DM_WINDOWED);
581 #if (defined(__APPLE__) && !defined(__arm__)) || defined(_WIN32)
582 else if (strSetting.Equals("videoscreen.blankdisplays"))
584 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
587 int value = g_guiSettings.GetResolution();
588 if (g_settings.m_ResInfo[value].bFullScreen)
589 pControl->SetEnabled(true);
591 pControl->SetEnabled(false);
595 #if defined(__APPLE__) && !defined(__arm__)
596 else if (strSetting.Equals("input.appleremotemode"))
598 int remoteMode = g_guiSettings.GetInt("input.appleremotemode");
600 // if it's not disabled, start the event server or else apple remote won't work
601 if ( remoteMode != APPLE_REMOTE_DISABLED )
603 g_guiSettings.SetBool("services.esenabled", true);
604 if (!g_application.StartEventServer())
605 CGUIDialogKaiToast::QueueNotification("DefaultIconWarning.png", g_localizeStrings.Get(33102), g_localizeStrings.Get(33100));
608 // if XBMC helper is running, prompt user before effecting change
609 if ( XBMCHelper::GetInstance().IsRunning() && XBMCHelper::GetInstance().GetMode()!=remoteMode )
612 if (!CGUIDialogYesNo::ShowAndGetInput(13144, 13145, 13146, 13147, -1, -1, cancelled, 10000))
614 // user declined, restore previous spinner state and appleremote mode
615 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
616 g_guiSettings.SetInt("input.appleremotemode", XBMCHelper::GetInstance().GetMode());
617 pControl->SetValue(XBMCHelper::GetInstance().GetMode());
621 // reload configuration
622 XBMCHelper::GetInstance().Configure();
627 // set new configuration.
628 XBMCHelper::GetInstance().Configure();
631 if (XBMCHelper::GetInstance().ErrorStarting() == true)
633 // inform user about error
634 CGUIDialogOK::ShowAndGetInput(13620, 13621, 20022, 20022);
636 // reset spinner to disabled state
637 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
638 pControl->SetValue(APPLE_REMOTE_DISABLED);
641 else if (strSetting.Equals("input.appleremotealwayson"))
643 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
646 int value = g_guiSettings.GetInt("input.appleremotemode");
647 if (value != APPLE_REMOTE_DISABLED)
648 pControl->SetEnabled(true);
650 pControl->SetEnabled(false);
653 else if (strSetting.Equals("input.appleremotesequencetime"))
655 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
658 int value = g_guiSettings.GetInt("input.appleremotemode");
659 if (value == APPLE_REMOTE_UNIVERSAL)
660 pControl->SetEnabled(true);
662 pControl->SetEnabled(false);
666 else if (strSetting.Equals("filelists.allowfiledeletion"))
668 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
669 if (pControl) pControl->SetEnabled(!g_settings.GetCurrentProfile().filesLocked() || g_passwordManager.bMasterUser);
671 else if (strSetting.Equals("filelists.showaddsourcebuttons"))
673 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
674 if (pControl) pControl->SetEnabled(g_settings.GetCurrentProfile().canWriteSources() || g_passwordManager.bMasterUser);
676 else if (strSetting.Equals("masterlock.startuplock"))
678 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
679 if (pControl) pControl->SetEnabled(g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE);
681 else if (!strSetting.Equals("services.esenabled")
682 && strSetting.Left(11).Equals("services.es"))
684 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
685 if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("services.esenabled"));
687 else if (strSetting.Equals("audiocds.quality"))
688 { // only visible if we are doing non-WAV ripping
689 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
690 if (pControl) pControl->SetEnabled(g_guiSettings.GetInt("audiocds.encoder") != CDDARIP_ENCODER_WAV &&
691 g_guiSettings.GetInt("audiocds.encoder") != CDDARIP_ENCODER_FLAC);
693 else if (strSetting.Equals("audiocds.bitrate"))
694 { // only visible if we are ripping to CBR
695 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
696 if (pControl) pControl->SetEnabled(g_guiSettings.GetInt("audiocds.encoder") != CDDARIP_ENCODER_WAV &&
697 g_guiSettings.GetInt("audiocds.encoder") != CDDARIP_ENCODER_FLAC &&
698 g_guiSettings.GetInt("audiocds.quality") == CDDARIP_QUALITY_CBR);
700 else if (strSetting.Equals("audiocds.compressionlevel"))
701 { // only visible if we are doing FLAC ripping
702 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
703 if (pControl) pControl->SetEnabled(g_guiSettings.GetInt("audiocds.encoder") == CDDARIP_ENCODER_FLAC);
706 strSetting.Equals("audiooutput.passthroughdevice") ||
707 strSetting.Equals("audiooutput.ac3passthrough") ||
708 strSetting.Equals("audiooutput.dtspassthrough") ||
709 strSetting.Equals("audiooutput.passthroughaac") ||
710 strSetting.Equals("audiooutput.passthroughmp1") ||
711 strSetting.Equals("audiooutput.passthroughmp2") ||
712 strSetting.Equals("audiooutput.passthroughmp3"))
713 { // only visible if we are in digital mode
714 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
715 if (pControl) pControl->SetEnabled(AUDIO_IS_BITSTREAM(g_guiSettings.GetInt("audiooutput.mode")));
717 else if (strSetting.Equals("musicplayer.crossfade"))
719 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
720 if (pControl) pControl->SetEnabled(g_guiSettings.GetString("audiooutput.audiodevice").find("wasapi:") == CStdString::npos);
722 else if (strSetting.Equals("musicplayer.crossfadealbumtracks"))
724 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
725 if (pControl) pControl->SetEnabled(g_guiSettings.GetInt("musicplayer.crossfade") > 0 &&
726 g_guiSettings.GetString("audiooutput.audiodevice").find("wasapi:") == CStdString::npos);
728 #ifdef HAS_WEB_SERVER
729 else if (strSetting.Equals("services.webserverusername") ||
730 strSetting.Equals("services.webserverpassword"))
732 CGUIEditControl *pControl = (CGUIEditControl *)GetControl(pSettingControl->GetID());
734 pControl->SetEnabled(g_guiSettings.GetBool("services.webserver"));
738 else if ( strSetting.Equals("services.airplaypassword") ||
739 strSetting.Equals("services.useairplaypassword"))
741 if (strSetting.Equals("services.airplaypassword"))
743 CGUIEditControl *pControl = (CGUIEditControl *)GetControl(pSettingControl->GetID());
745 pControl->SetEnabled(g_guiSettings.GetBool("services.useairplaypassword"));
747 else//useairplaypassword
749 CGUIRadioButtonControl *pControl = (CGUIRadioButtonControl *)GetControl(pSettingControl->GetID());
751 pControl->SetEnabled(g_guiSettings.GetBool("services.airplay"));
754 //set credentials to airplay server
755 if (g_guiSettings.GetBool("services.airplay"))
757 CStdString password = g_guiSettings.GetString("services.airplaypassword");
758 CAirPlayServer::SetCredentials(g_guiSettings.GetBool("services.useairplaypassword"),
763 else if (strSetting.Equals("network.ipaddress") || strSetting.Equals("network.subnet") || strSetting.Equals("network.gateway") || strSetting.Equals("network.dns"))
766 bool enabled = (geteuid() == 0);
768 bool enabled = false;
770 CGUISpinControlEx* pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.assignment")->GetID());
772 enabled = (pControl1->GetValue() == NETWORK_STATIC);
774 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
775 if (pControl) pControl->SetEnabled(enabled);
777 else if (strSetting.Equals("network.assignment"))
779 CGUISpinControlEx* pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.assignment")->GetID());
780 #ifdef HAS_LINUX_NETWORK
782 pControl1->SetEnabled(geteuid() == 0);
785 else if (strSetting.Equals("network.essid") || strSetting.Equals("network.enc") || strSetting.Equals("network.key"))
787 // Get network information
788 CGUISpinControlEx *ifaceControl = (CGUISpinControlEx *)GetControl(GetSetting("network.interface")->GetID());
789 CStdString ifaceName = ifaceControl->GetLabel();
790 CNetworkInterface* iface = g_application.getNetwork().GetInterfaceByName(ifaceName);
791 bool bIsWireless = iface->IsWireless();
793 #ifdef HAS_LINUX_NETWORK
794 bool enabled = bIsWireless && (geteuid() == 0);
796 bool enabled = bIsWireless;
798 CGUISpinControlEx* pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.assignment")->GetID());
800 enabled &= (pControl1->GetValue() != NETWORK_DISABLED);
802 if (strSetting.Equals("network.key"))
804 pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.enc")->GetID());
805 if (pControl1) enabled &= (pControl1->GetValue() != ENC_NONE);
808 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
809 if (pControl) pControl->SetEnabled(enabled);
811 else if (strSetting.Equals("network.httpproxyserver") || strSetting.Equals("network.httpproxyport") ||
812 strSetting.Equals("network.httpproxyusername") || strSetting.Equals("network.httpproxypassword"))
814 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
815 if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("network.usehttpproxy"));
817 #ifdef HAS_LINUX_NETWORK
818 else if (strSetting.Equals("network.key"))
820 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
821 CGUISpinControlEx* pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.enc")->GetID());
822 if (pControl && pControl1)
823 pControl->SetEnabled(!pControl1->IsDisabled() && pControl1->GetValue() > 0);
825 else if (strSetting.Equals("network.save"))
827 CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(pSettingControl->GetID());
828 pControl->SetEnabled(geteuid() == 0);
831 else if (strSetting.Equals("scrobbler.lastfmusername") || strSetting.Equals("scrobbler.lastfmpass"))
833 CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(pSettingControl->GetID());
835 pControl->SetEnabled(g_guiSettings.GetBool("scrobbler.lastfmsubmit") | g_guiSettings.GetBool("scrobbler.lastfmsubmitradio"));
837 else if (strSetting.Equals("scrobbler.librefmusername") || strSetting.Equals("scrobbler.librefmpass"))
839 CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(pSettingControl->GetID());
840 if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("scrobbler.librefmsubmit"));
842 else if (strSetting.Equals("subtitles.color") || strSetting.Equals("subtitles.style") || strSetting.Equals("subtitles.charset"))
844 CGUIControl *pControl = (CGUIControl *)GetControl(GetSetting(strSetting)->GetID());
845 pControl->SetEnabled(CUtil::IsUsingTTFSubtitles());
847 else if (strSetting.Equals("locale.charset"))
848 { // TODO: Determine whether we are using a TTF font or not.
849 // CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
850 // if (pControl) pControl->SetEnabled(g_guiSettings.GetString("lookandfeel.font").Right(4) == ".ttf");
852 else if (strSetting.Equals("screensaver.settings"))
854 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
856 if (CAddonMgr::Get().GetAddon(g_guiSettings.GetString("screensaver.mode"), addon, ADDON_SCREENSAVER))
857 pControl->SetEnabled(addon->HasSettings());
859 pControl->SetEnabled(false);
861 else if (strSetting.Equals("screensaver.preview") ||
862 strSetting.Equals("screensaver.usedimonpause") ||
863 strSetting.Equals("screensaver.usemusicvisinstead"))
865 CGUIControl *pControl = (CGUIControl *)GetControl(GetSetting(strSetting)->GetID());
866 pControl->SetEnabled(!g_guiSettings.GetString("screensaver.mode").IsEmpty());
867 if (strSetting.Equals("screensaver.usedimonpause") && g_guiSettings.GetString("screensaver.mode").Equals("screensaver.xbmc.builtin.dim"))
868 pControl->SetEnabled(false);
870 else if (strSetting.Left(16).Equals("weather.areacode"))
872 CSettingString *pSetting = (CSettingString *)GetSetting(strSetting)->GetSetting();
873 CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(GetSetting(strSetting)->GetID());
874 pControl->SetLabel2(CWeather::GetAreaCity(pSetting->GetData()));
876 else if (strSetting.Equals("musicfiles.trackformat"))
878 if (m_strOldTrackFormat != g_guiSettings.GetString("musicfiles.trackformat"))
880 CUtil::DeleteMusicDatabaseDirectoryCache();
881 m_strOldTrackFormat = g_guiSettings.GetString("musicfiles.trackformat");
884 else if (strSetting.Equals("musicfiles.trackformatright"))
886 if (m_strOldTrackFormatRight != g_guiSettings.GetString("musicfiles.trackformatright"))
888 CUtil::DeleteMusicDatabaseDirectoryCache();
889 m_strOldTrackFormatRight = g_guiSettings.GetString("musicfiles.trackformatright");
892 #ifdef HAS_TIME_SERVER
893 else if (strSetting.Equals("locale.timeserveraddress"))
895 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
896 if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("locale.timeserver"));
899 else if (strSetting.Equals("audiocds.recordingpath") || strSetting.Equals("debug.screenshotpath"))
901 CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(pSettingControl->GetID());
902 if (pControl && g_guiSettings.GetString(strSetting, false).IsEmpty())
903 pControl->SetLabel2("");
905 else if (strSetting.Equals("lookandfeel.rssedit"))
907 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
908 pControl->SetEnabled(g_guiSettings.GetBool("lookandfeel.enablerssfeeds"));
910 else if (strSetting.Equals("videoplayer.pauseafterrefreshchange"))
912 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
913 if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("videoplayer.adjustrefreshrate"));
915 else if (strSetting.Equals("videoplayer.synctype"))
917 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
918 if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("videoplayer.usedisplayasclock"));
920 else if (strSetting.Equals("videoplayer.maxspeedadjust"))
922 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
925 bool enabled = (g_guiSettings.GetBool("videoplayer.usedisplayasclock")) &&
926 (g_guiSettings.GetInt("videoplayer.synctype") == SYNC_RESAMPLE);
927 pControl->SetEnabled(enabled);
930 else if (strSetting.Equals("videoplayer.resamplequality"))
932 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
935 bool enabled = (g_guiSettings.GetBool("videoplayer.usedisplayasclock")) &&
936 (g_guiSettings.GetInt("videoplayer.synctype") == SYNC_RESAMPLE);
937 pControl->SetEnabled(enabled);
940 else if (strSetting.Equals("weather.scriptsettings"))
943 if (CAddonMgr::Get().GetAddon(g_guiSettings.GetString("weather.script"), addon, ADDON_SCRIPT_WEATHER))
945 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
947 pControl->SetEnabled(addon->HasSettings());
950 #if defined(_LINUX) && !defined(__APPLE__)
951 else if (strSetting.Equals("audiooutput.custompassthrough"))
953 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
954 if (AUDIO_IS_BITSTREAM(g_guiSettings.GetInt("audiooutput.mode")))
956 if (pControl) pControl->SetEnabled(g_guiSettings.GetString("audiooutput.passthroughdevice").Equals("custom"));
960 if (pControl) pControl->SetEnabled(false);
963 else if (strSetting.Equals("audiooutput.customdevice"))
965 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
966 if (pControl) pControl->SetEnabled(g_guiSettings.GetString("audiooutput.audiodevice").Equals("custom"));
972 void CGUIWindowSettingsCategory::UpdateRealTimeSettings()
974 // date and time used to be here
977 void CGUIWindowSettingsCategory::OnClick(CBaseSettingControl *pSettingControl)
979 CStdString strSetting = pSettingControl->GetSetting()->GetSetting();
980 if (strSetting.Left(16).Equals("weather.areacode"))
982 CStdString strSearch;
983 if (CGUIDialogKeyboard::ShowAndGetInput(strSearch, g_localizeStrings.Get(14024), false))
985 strSearch.Replace(" ", "+");
986 CStdString strResult = ((CSettingString *)pSettingControl->GetSetting())->GetData();
987 if (g_weatherManager.GetSearchResults(strSearch, strResult))
989 ((CSettingString *)pSettingControl->GetSetting())->SetData(strResult);
990 // Update the labels on the location spinner
991 g_weatherManager.Reset();
992 // Refresh the weather using the new location
993 g_weatherManager.Refresh();
997 else if (strSetting.Equals("weather.scriptsettings"))
999 CStdString name = g_guiSettings.GetString("weather.script");
1001 if (CAddonMgr::Get().GetAddon(name, addon, ADDON_SCRIPT_WEATHER))
1002 { // TODO: maybe have ShowAndGetInput return a bool if settings changed, then only reset weather if true.
1003 CGUIDialogAddonSettings::ShowAndGetInput(addon);
1004 g_weatherManager.Refresh();
1007 else if (strSetting.Equals("lookandfeel.rssedit"))
1010 CAddonMgr::Get().GetAddon("script.rss.editor",addon);
1013 if (!CGUIDialogYesNo::ShowAndGetInput(g_localizeStrings.Get(24076), g_localizeStrings.Get(24100),"RSS Editor",g_localizeStrings.Get(24101)))
1015 CAddonInstaller::Get().Install("script.rss.editor", true, "", false);
1017 CBuiltins::Execute("RunScript(script.rss.editor)");
1019 else if (pSettingControl->GetSetting()->GetType() == SETTINGS_TYPE_ADDON)
1020 { // prompt for the addon
1021 CSettingAddon *setting = (CSettingAddon *)pSettingControl->GetSetting();
1022 CStdString addonID = setting->GetData();
1023 if (CGUIWindowAddonBrowser::SelectAddonID(setting->m_type, addonID, setting->m_type == ADDON_SCREENSAVER || setting->m_type == ADDON_VIZ) == 1)
1024 setting->SetData(addonID);
1028 else if (strSetting.Equals("input.peripherals"))
1030 CGUIDialogPeripheralManager *dialog = (CGUIDialogPeripheralManager *)g_windowManager.GetWindow(WINDOW_DIALOG_PERIPHERAL_MANAGER);
1036 // if OnClick() returns false, the setting hasn't changed or doesn't
1037 // require immediate update
1038 if (!pSettingControl->OnClick())
1041 if (!pSettingControl->IsDelayed())
1045 if (pSettingControl->IsDelayed())
1046 { // delayed setting
1047 m_delayedSetting = pSettingControl;
1048 m_delayedTimer.StartZero();
1051 OnSettingChanged(pSettingControl);
1054 void CGUIWindowSettingsCategory::CheckForUpdates()
1056 for (unsigned int i = 0; i < m_vecSettings.size(); i++)
1058 CBaseSettingControl *pSettingControl = m_vecSettings[i];
1059 if (pSettingControl->NeedsUpdate())
1061 OnSettingChanged(pSettingControl);
1062 pSettingControl->Reset();
1067 void CGUIWindowSettingsCategory::OnSettingChanged(CBaseSettingControl *pSettingControl)
1069 CStdString strSetting = pSettingControl->GetSetting()->GetSetting();
1071 // ok, now check the various special things we need to do
1072 if (pSettingControl->GetSetting()->GetType() == SETTINGS_TYPE_ADDON)
1074 CSettingAddon *pSettingAddon = (CSettingAddon*)pSettingControl->GetSetting();
1075 if (pSettingAddon->m_type == ADDON_SKIN)
1077 g_application.ReloadSkin();
1079 else if (pSettingAddon->m_type == ADDON_SCRIPT_WEATHER)
1081 g_weatherManager.Refresh();
1084 else if (strSetting.Equals("musicplayer.visualisation"))
1085 { // new visualisation choosen...
1086 CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
1087 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1088 if (pControl->GetValue() == 0)
1089 pSettingString->SetData("None");
1091 pSettingString->SetData(pControl->GetCurrentLabel());
1093 else if (strSetting.Equals("debug.showloginfo"))
1095 if (g_guiSettings.GetBool("debug.showloginfo"))
1097 int level = std::max(g_advancedSettings.m_logLevelHint, LOG_LEVEL_DEBUG_FREEMEM);
1098 g_advancedSettings.m_logLevel = level;
1099 CLog::SetLogLevel(level);
1100 CLog::Log(LOGNOTICE, "Enabled debug logging due to GUI setting. Level %d.", level);
1104 int level = std::min(g_advancedSettings.m_logLevelHint, LOG_LEVEL_DEBUG/*LOG_LEVEL_NORMAL*/);
1105 CLog::Log(LOGNOTICE, "Disabled debug logging due to GUI setting. Level %d.", level);
1106 g_advancedSettings.m_logLevel = level;
1107 CLog::SetLogLevel(level);
1110 /*else if (strSetting.Equals("musicfiles.repeat"))
1112 g_playlistPlayer.SetRepeat(PLAYLIST_MUSIC_TEMP, g_guiSettings.GetBool("musicfiles.repeat") ? PLAYLIST::REPEAT_ALL : PLAYLIST::REPEAT_NONE);
1114 else if (strSetting.Equals("musiclibrary.cleanup"))
1116 CMusicDatabase musicdatabase;
1117 musicdatabase.Clean();
1118 CUtil::DeleteMusicDatabaseDirectoryCache();
1120 else if (strSetting.Equals("videolibrary.cleanup"))
1122 if (CGUIDialogYesNo::ShowAndGetInput(313, 333, 0, 0))
1124 CVideoDatabase videodatabase;
1125 videodatabase.Open();
1126 videodatabase.CleanDatabase();
1127 videodatabase.Close();
1130 else if (strSetting.Equals("videolibrary.export"))
1131 CBuiltins::Execute("exportlibrary(video)");
1132 else if (strSetting.Equals("musiclibrary.export"))
1133 CBuiltins::Execute("exportlibrary(music)");
1134 else if (strSetting.Equals("karaoke.export") )
1136 CContextButtons choices;
1137 choices.Add(1, g_localizeStrings.Get(22034));
1138 choices.Add(2, g_localizeStrings.Get(22035));
1140 int retVal = CGUIDialogContextMenu::ShowAndGetChoice(choices);
1143 CStdString path(g_settings.GetDatabaseFolder());
1145 g_mediaManager.GetLocalDrives(shares);
1146 if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares, g_localizeStrings.Get(661), path, true))
1148 CMusicDatabase musicdatabase;
1149 musicdatabase.Open();
1153 URIUtils::AddFileToFolder(path, "karaoke.html", path);
1154 musicdatabase.ExportKaraokeInfo( path, true );
1158 URIUtils::AddFileToFolder(path, "karaoke.csv", path);
1159 musicdatabase.ExportKaraokeInfo( path, false );
1161 musicdatabase.Close();
1165 else if (strSetting.Equals("videolibrary.import"))
1169 g_mediaManager.GetLocalDrives(shares);
1170 if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares, g_localizeStrings.Get(651) , path))
1172 CVideoDatabase videodatabase;
1173 videodatabase.Open();
1174 videodatabase.ImportFromXML(path);
1175 videodatabase.Close();
1178 else if (strSetting.Equals("musiclibrary.import"))
1182 g_mediaManager.GetLocalDrives(shares);
1183 if (CGUIDialogFileBrowser::ShowAndGetFile(shares, "musicdb.xml", g_localizeStrings.Get(651) , path))
1185 CMusicDatabase musicdatabase;
1186 musicdatabase.Open();
1187 musicdatabase.ImportFromXML(path);
1188 musicdatabase.Close();
1191 else if (strSetting.Equals("karaoke.importcsv"))
1193 CStdString path(g_settings.GetDatabaseFolder());
1195 g_mediaManager.GetLocalDrives(shares);
1196 if (CGUIDialogFileBrowser::ShowAndGetFile(shares, "karaoke.csv", g_localizeStrings.Get(651) , path))
1198 CMusicDatabase musicdatabase;
1199 musicdatabase.Open();
1200 musicdatabase.ImportKaraokeInfo(path);
1201 musicdatabase.Close();
1204 else if (strSetting.Equals("scrobbler.lastfmsubmit") || strSetting.Equals("scrobbler.lastfmsubmitradio") || strSetting.Equals("scrobbler.lastfmusername") || strSetting.Equals("scrobbler.lastfmpass"))
1206 CStdString strPassword=g_guiSettings.GetString("scrobbler.lastfmpass");
1207 CStdString strUserName=g_guiSettings.GetString("scrobbler.lastfmusername");
1208 if ((g_guiSettings.GetBool("scrobbler.lastfmsubmit") ||
1209 g_guiSettings.GetBool("scrobbler.lastfmsubmitradio")) &&
1210 !strUserName.IsEmpty() && !strPassword.IsEmpty())
1212 CLastfmScrobbler::GetInstance()->Init();
1216 CLastfmScrobbler::GetInstance()->Term();
1219 else if (strSetting.Equals("scrobbler.librefmsubmit") || strSetting.Equals("scrobbler.librefmsubmitradio") || strSetting.Equals("scrobbler.librefmusername") || strSetting.Equals("scrobbler.librefmpass"))
1221 CStdString strPassword=g_guiSettings.GetString("scrobbler.librefmpass");
1222 CStdString strUserName=g_guiSettings.GetString("scrobbler.librefmusername");
1223 if ((g_guiSettings.GetBool("scrobbler.librefmsubmit") ||
1224 g_guiSettings.GetBool("scrobbler.librefmsubmitradio")) &&
1225 !strUserName.IsEmpty() && !strPassword.IsEmpty())
1227 CLibrefmScrobbler::GetInstance()->Init();
1231 CLibrefmScrobbler::GetInstance()->Term();
1234 else if (strSetting.Left(22).Equals("MusicPlayer.ReplayGain"))
1235 { // Update our replaygain settings
1236 g_guiSettings.m_replayGain.iType = g_guiSettings.GetInt("musicplayer.replaygaintype");
1237 g_guiSettings.m_replayGain.iPreAmp = g_guiSettings.GetInt("musicplayer.replaygainpreamp");
1238 g_guiSettings.m_replayGain.iNoGainPreAmp = g_guiSettings.GetInt("musicplayer.replaygainnogainpreamp");
1239 g_guiSettings.m_replayGain.bAvoidClipping = g_guiSettings.GetBool("musicplayer.replaygainavoidclipping");
1241 else if (strSetting.Equals("audiooutput.audiodevice"))
1243 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1244 #if !defined(__APPLE__)
1245 g_guiSettings.SetString("audiooutput.audiodevice", m_AnalogAudioSinkMap[pControl->GetCurrentLabel()]);
1247 g_guiSettings.SetString("audiooutput.audiodevice", pControl->GetCurrentLabel());
1251 else if (strSetting.Equals("audiooutput.passthroughdevice"))
1253 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1254 #if defined(_LINUX) && !defined(__APPLE__)
1255 g_guiSettings.SetString("audiooutput.passthroughdevice", m_DigitalAudioSinkMap[pControl->GetCurrentLabel()]);
1256 #elif !defined(__arm__)
1257 g_guiSettings.SetString("audiooutput.passthroughdevice", pControl->GetCurrentLabel());
1262 else if (strSetting.Equals("videoscreen.haslcd"))
1265 CLCDFactory factory;
1267 g_lcd = factory.Create();
1268 g_lcd->Initialize();
1271 #ifdef HAS_WEB_SERVER
1272 else if ( strSetting.Equals("services.webserver") || strSetting.Equals("services.webserverport"))
1274 if (strSetting.Equals("services.webserverport"))
1275 ValidatePortNumber(pSettingControl, "8080", "80");
1276 g_application.StopWebServer();
1277 if (g_guiSettings.GetBool("services.webserver"))
1278 if (!g_application.StartWebServer())
1280 CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33101), "", g_localizeStrings.Get(33100), "");
1281 g_guiSettings.SetBool("services.webserver", false);
1284 else if (strSetting.Equals("services.webserverusername") || strSetting.Equals("services.webserverpassword"))
1286 g_application.m_WebServer.SetCredentials(g_guiSettings.GetString("services.webserverusername"), g_guiSettings.GetString("services.webserverpassword"));
1289 else if (strSetting.Equals("services.zeroconf"))
1292 //ifdef zeroconf here because it's only found in guisettings if defined
1293 CZeroconf::GetInstance()->Stop();
1294 if(g_guiSettings.GetBool("services.zeroconf"))
1295 CZeroconf::GetInstance()->Start();
1298 else if (strSetting.Equals("services.airplay"))
1301 if (g_guiSettings.GetBool("services.airplay"))
1302 g_application.StartAirplayServer();//will stop the server before internal
1304 g_application.StopAirplayServer(true);//will stop the server before internal
1307 else if (strSetting.Equals("network.ipaddress"))
1309 if (g_guiSettings.GetInt("network.assignment") == NETWORK_STATIC)
1311 CStdString strDefault = g_guiSettings.GetString("network.ipaddress").Left(g_guiSettings.GetString("network.ipaddress").ReverseFind('.'))+".1";
1312 if (g_guiSettings.GetString("network.gateway").Equals("0.0.0.0"))
1313 g_guiSettings.SetString("network.gateway",strDefault);
1314 if (g_guiSettings.GetString("network.dns").Equals("0.0.0.0"))
1315 g_guiSettings.SetString("network.dns",strDefault);
1320 else if (strSetting.Equals("network.httpproxyport"))
1322 ValidatePortNumber(pSettingControl, "8080", "8080", false);
1324 else if (strSetting.Equals("videoplayer.calibrate") || strSetting.Equals("videoscreen.guicalibration"))
1325 { // activate the video calibration screen
1326 g_windowManager.ActivateWindow(WINDOW_SCREEN_CALIBRATION);
1328 else if (strSetting.Equals("videoscreen.testpattern"))
1329 { // activate the test pattern
1330 g_windowManager.ActivateWindow(WINDOW_TEST_PATTERN);
1332 else if (strSetting.Equals("subtitles.height"))
1334 if (!CUtil::IsUsingTTFSubtitles())
1336 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1337 ((CSettingInt *)pSettingControl->GetSetting())->FromString(pControl->GetCurrentLabel());
1340 else if (strSetting.Equals("subtitles.font"))
1342 CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
1343 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1344 pSettingString->SetData(pControl->GetCurrentLabel());
1345 CSetting *pSetting = (CSetting *)g_guiSettings.GetSetting("subtitles.height");
1346 FillInSubtitleHeights(pSetting, (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID()));
1348 else if (strSetting.Equals("subtitles.charset"))
1350 CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
1351 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1352 CStdString newCharset="DEFAULT";
1353 if (pControl->GetValue()!=0)
1354 newCharset = g_charsetConverter.getCharsetNameByLabel(pControl->GetCurrentLabel());
1355 if (newCharset != "" && (newCharset != pSettingString->GetData() || newCharset=="DEFAULT"))
1357 pSettingString->SetData(newCharset);
1358 g_charsetConverter.reset();
1361 else if (strSetting.Equals("karaoke.fontheight"))
1363 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1364 ((CSettingInt *)pSettingControl->GetSetting())->FromString(pControl->GetCurrentLabel());
1366 else if (strSetting.Equals("karaoke.font"))
1368 CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
1369 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1370 pSettingString->SetData(pControl->GetCurrentLabel());
1371 CSetting *pSetting = (CSetting *)g_guiSettings.GetSetting("karaoke.fontheight");
1372 FillInSubtitleHeights(pSetting, (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID()));
1374 else if (strSetting.Equals("karaoke.charset"))
1376 CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
1377 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1378 CStdString newCharset="DEFAULT";
1379 if (pControl->GetValue()!=0)
1380 newCharset = g_charsetConverter.getCharsetNameByLabel(pControl->GetCurrentLabel());
1381 if (newCharset != "" && (newCharset != pSettingString->GetData() || newCharset=="DEFAULT"))
1383 pSettingString->SetData(newCharset);
1384 g_charsetConverter.reset();
1387 else if (strSetting.Equals("locale.charset"))
1389 CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
1390 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1391 CStdString newCharset="DEFAULT";
1392 if (pControl->GetValue()!=0)
1393 newCharset = g_charsetConverter.getCharsetNameByLabel(pControl->GetCurrentLabel());
1394 if (newCharset != "" && (newCharset != pSettingString->GetData() || newCharset=="DEFAULT"))
1396 pSettingString->SetData(newCharset);
1397 g_charsetConverter.reset();
1400 else if (strSetting.Equals("lookandfeel.font"))
1401 { // new font choosen...
1402 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1403 CStdString strSkinFontSet = m_SkinFontSetIDs[pControl->GetCurrentLabel()];
1404 if (strSkinFontSet != ".svn" && strSkinFontSet != g_guiSettings.GetString("lookandfeel.font"))
1406 g_guiSettings.SetString("lookandfeel.font", strSkinFontSet);
1407 g_application.ReloadSkin();
1410 else if (strSetting.Equals("lookandfeel.soundskin"))
1411 { // new sound skin choosen...
1412 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1413 if (pControl->GetValue()==0)
1414 g_guiSettings.SetString("lookandfeel.soundskin", "OFF");
1415 else if (pControl->GetValue()==1)
1416 g_guiSettings.SetString("lookandfeel.soundskin", "SKINDEFAULT");
1418 g_guiSettings.SetString("lookandfeel.soundskin", pControl->GetCurrentLabel());
1420 g_audioManager.Enable(true);
1421 g_audioManager.Load();
1423 else if (strSetting.Equals("input.enablemouse"))
1425 g_Mouse.SetEnabled(g_guiSettings.GetBool("input.enablemouse"));
1427 else if (strSetting.Equals("videoscreen.screen"))
1429 DisplayMode mode = g_guiSettings.GetInt("videoscreen.screen");
1431 FillInResolutions("videoscreen.resolution", mode, RES_DESKTOP, true);
1433 else if (strSetting.Equals("videoscreen.resolution"))
1435 RESOLUTION nextRes = (RESOLUTION) g_guiSettings.GetInt("videoscreen.resolution");
1437 FillInRefreshRates("videoscreen.screenmode", nextRes, true);
1439 else if (strSetting.Equals("videoscreen.screenmode"))
1441 int iControlID = pSettingControl->GetID();
1442 CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), iControlID);
1443 g_windowManager.SendMessage(msg);
1444 RESOLUTION nextRes = (RESOLUTION)msg.GetParam1();
1446 OnRefreshRateChanged(nextRes);
1448 else if (strSetting.Equals("videoscreen.vsync"))
1450 int iControlID = pSettingControl->GetID();
1451 CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), iControlID);
1452 g_windowManager.SendMessage(msg);
1453 // DXMERGE: This may be useful
1454 // g_videoConfig.SetVSyncMode((VSYNC)msg.GetParam1());
1456 else if (strSetting.Equals("videoscreen.fakefullscreen"))
1458 if (g_graphicsContext.IsFullScreenRoot())
1459 g_graphicsContext.SetVideoResolution(g_graphicsContext.GetVideoResolution(), true);
1461 else if (strSetting.Equals("locale.language"))
1462 { // new language chosen...
1463 CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
1464 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1465 CStdString strLanguage = pControl->GetCurrentLabel();
1466 if (strLanguage != ".svn" && strLanguage != pSettingString->GetData())
1468 CStdString strLangInfoPath;
1469 strLangInfoPath.Format("special://xbmc/language/%s/langinfo.xml", strLanguage.c_str());
1470 g_langInfo.Load(strLangInfoPath);
1472 if (g_langInfo.ForceUnicodeFont() && !g_fontManager.IsFontSetUnicode())
1474 CLog::Log(LOGINFO, "Language needs a ttf font, loading first ttf font available");
1475 CStdString strFontSet;
1476 if (g_fontManager.GetFirstFontSetUnicode(strFontSet))
1477 strLanguage = strFontSet;
1479 CLog::Log(LOGERROR, "No ttf font found but needed: %s", strFontSet.c_str());
1481 g_guiSettings.SetString("locale.language", strLanguage);
1483 g_charsetConverter.reset();
1485 CStdString strLanguagePath;
1486 strLanguagePath.Format("special://xbmc/language/%s/strings.xml", strLanguage.c_str());
1487 g_localizeStrings.Load(strLanguagePath);
1489 // also tell our weather and skin to reload as these are localized
1490 g_weatherManager.Refresh();
1491 g_application.ReloadSkin();
1494 else if (strSetting.Equals("lookandfeel.skintheme"))
1495 { //a new Theme was chosen
1496 CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
1497 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1499 CStdString strSkinTheme;
1501 if (pControl->GetValue() == 0) // Use default theme
1502 strSkinTheme = "SKINDEFAULT";
1504 strSkinTheme = pControl->GetCurrentLabel();
1506 if (strSkinTheme != pSettingString->GetData())
1508 g_guiSettings.SetString("lookandfeel.skintheme", strSkinTheme);
1509 // also set the default color theme
1510 CStdString colorTheme(URIUtils::ReplaceExtension(strSkinTheme, ".xml"));
1511 if (colorTheme.Equals("Textures.xml"))
1512 colorTheme = "defaults.xml";
1513 g_guiSettings.SetString("lookandfeel.skincolors", colorTheme);
1514 g_application.ReloadSkin();
1517 else if (strSetting.Equals("lookandfeel.skincolors"))
1518 { //a new color was chosen
1519 CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
1520 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1522 CStdString strSkinColor;
1524 if (pControl->GetValue() == 0) // Use default colors
1525 strSkinColor = "SKINDEFAULT";
1527 strSkinColor = pControl->GetCurrentLabel() + ".xml";
1529 if (strSkinColor != pSettingString->GetData())
1531 g_guiSettings.SetString("lookandfeel.skincolors", strSkinColor);
1532 g_application.ReloadSkin();
1535 else if (strSetting.Equals("videoplayer.displayresolution"))
1537 CSettingInt *pSettingInt = (CSettingInt *)pSettingControl->GetSetting();
1538 int iControlID = pSettingControl->GetID();
1539 CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), iControlID);
1540 g_windowManager.SendMessage(msg);
1541 pSettingInt->SetData(msg.GetParam1());
1543 else if (strSetting.Equals("videoscreen.flickerfilter") || strSetting.Equals("videoscreen.soften"))
1545 g_graphicsContext.SetVideoResolution(g_guiSettings.m_LookAndFeelResolution);
1547 else if (strSetting.Equals("screensaver.preview"))
1549 g_application.ActivateScreenSaver(true);
1551 else if (strSetting.Equals("screensaver.settings"))
1554 if (CAddonMgr::Get().GetAddon(g_guiSettings.GetString("screensaver.mode"), addon, ADDON_SCREENSAVER))
1555 CGUIDialogAddonSettings::ShowAndGetInput(addon);
1557 else if (strSetting.Equals("debug.screenshotpath") || strSetting.Equals("audiocds.recordingpath") || strSetting.Equals("subtitles.custompath"))
1559 CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
1560 CStdString path = g_guiSettings.GetString(strSetting,false);
1563 g_mediaManager.GetNetworkLocations(shares);
1564 g_mediaManager.GetLocalDrives(shares);
1567 bool bWriteOnly = true;
1569 if (strSetting.Equals("subtitles.custompath"))
1572 shares = g_settings.m_videoSources;
1573 g_mediaManager.GetLocalDrives(shares);
1575 if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares, g_localizeStrings.Get(pSettingString->m_iHeadingString), path, bWriteOnly))
1577 pSettingString->SetData(path);
1580 else if (strSetting.Left(22).Equals("MusicPlayer.ReplayGain"))
1581 { // Update our replaygain settings
1582 g_guiSettings.m_replayGain.iType = g_guiSettings.GetInt("musicplayer.replaygaintype");
1583 g_guiSettings.m_replayGain.iPreAmp = g_guiSettings.GetInt("musicplayer.replaygainpreamp");
1584 g_guiSettings.m_replayGain.iNoGainPreAmp = g_guiSettings.GetInt("musicplayer.replaygainnogainpreamp");
1585 g_guiSettings.m_replayGain.bAvoidClipping = g_guiSettings.GetBool("musicplayer.replaygainavoidclipping");
1587 else if (strSetting.Equals("locale.country"))
1589 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1591 const CStdString& strRegion=pControl->GetCurrentLabel();
1592 g_langInfo.SetCurrentRegion(strRegion);
1593 g_guiSettings.SetString("locale.country", strRegion);
1594 g_weatherManager.Refresh(); // need to reset our weather, as temperatures need re-translating.
1596 #ifdef HAS_TIME_SERVER
1597 else if (strSetting.Equals("locale.timeserver") || strSetting.Equals("locale.timeserveraddress"))
1599 g_application.StopTimeServer();
1600 if (g_guiSettings.GetBool("locale.timeserver"))
1601 g_application.StartTimeServer();
1604 else if (strSetting.Equals("smb.winsserver") || strSetting.Equals("smb.workgroup") )
1606 if (g_guiSettings.GetString("smb.winsserver") == "0.0.0.0")
1607 g_guiSettings.SetString("smb.winsserver", "");
1609 /* okey we really don't need to restarat, only deinit samba, but that could be damn hard if something is playing*/
1610 //TODO - General way of handling setting changes that require restart
1612 CGUIDialogOK *dlg = (CGUIDialogOK *)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
1614 dlg->SetHeading( g_localizeStrings.Get(14038) );
1615 dlg->SetLine( 0, g_localizeStrings.Get(14039) );
1616 dlg->SetLine( 1, g_localizeStrings.Get(14040));
1617 dlg->SetLine( 2, "");
1620 if (dlg->IsConfirmed())
1623 g_application.getApplicationMessenger().RestartApp();
1626 else if (strSetting.Equals("services.upnpserver"))
1629 if (g_guiSettings.GetBool("services.upnpserver"))
1630 g_application.StartUPnPServer();
1632 g_application.StopUPnPServer();
1635 else if (strSetting.Equals("services.upnprenderer"))
1638 if (g_guiSettings.GetBool("services.upnprenderer"))
1639 g_application.StartUPnPRenderer();
1641 g_application.StopUPnPRenderer();
1644 else if (strSetting.Equals("services.esenabled"))
1646 #ifdef HAS_EVENT_SERVER
1647 if (g_guiSettings.GetBool("services.esenabled"))
1649 if (!g_application.StartEventServer())
1651 CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33102), "", g_localizeStrings.Get(33100), "");
1652 g_guiSettings.SetBool("services.esenabled", false);
1653 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
1654 if (pControl) pControl->SetEnabled(false);
1659 if (!g_application.StopEventServer(true, true))
1661 g_guiSettings.SetBool("services.esenabled", true);
1662 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
1663 if (pControl) pControl->SetEnabled(true);
1668 if (g_guiSettings.GetBool("services.esenabled"))
1670 if (!g_application.StartJSONRPCServer())
1671 CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33103), "", g_localizeStrings.Get(33100), "");
1674 g_application.StopJSONRPCServer(false);
1677 else if (strSetting.Equals("services.esport"))
1679 #ifdef HAS_EVENT_SERVER
1680 ValidatePortNumber(pSettingControl, "9777", "9777");
1681 //restart eventserver without asking user
1682 if (g_application.StopEventServer(true, false))
1684 if (!g_application.StartEventServer())
1685 CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33102), "", g_localizeStrings.Get(33100), "");
1687 #if defined(__APPLE__) && !defined(__arm__)
1688 //reconfigure XBMCHelper for port changes
1689 XBMCHelper::GetInstance().Configure();
1693 else if (strSetting.Equals("services.esallinterfaces"))
1695 #ifdef HAS_EVENT_SERVER
1696 if (g_guiSettings.GetBool("services.esenabled"))
1698 if (g_application.StopEventServer(true, true))
1700 if (!g_application.StartEventServer())
1701 CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33102), "", g_localizeStrings.Get(33100), "");
1705 g_guiSettings.SetBool("services.esenabled", true);
1706 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
1707 if (pControl) pControl->SetEnabled(true);
1712 if (g_guiSettings.GetBool("services.esenabled"))
1714 if (!g_application.StartJSONRPCServer())
1715 CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33103), "", g_localizeStrings.Get(33100), "");
1718 g_application.StopJSONRPCServer(false);
1721 else if (strSetting.Equals("services.esinitialdelay") ||
1722 strSetting.Equals("services.escontinuousdelay"))
1724 #ifdef HAS_EVENT_SERVER
1725 if (g_guiSettings.GetBool("services.esenabled"))
1727 g_application.RefreshEventServer();
1731 else if (strSetting.Equals("masterlock.lockcode"))
1733 // Now Prompt User to enter the old and then the new MasterCode!
1734 if(g_passwordManager.SetMasterLockMode())
1736 // We asked for the master password and saved the new one!
1737 // Nothing todo here
1740 else if (strSetting.Equals("network.interface"))
1742 NetworkInterfaceChanged();
1744 #ifdef HAS_LINUX_NETWORK
1745 else if (strSetting.Equals("network.save"))
1747 NetworkAssignment iAssignment;
1748 CStdString sIPAddress;
1749 CStdString sNetworkMask;
1750 CStdString sDefaultGateway;
1751 CStdString sWirelessNetwork;
1752 CStdString sWirelessKey;
1754 EncMode iWirelessEnc;
1755 CStdString ifaceName;
1757 CGUISpinControlEx *ifaceControl = (CGUISpinControlEx *)GetControl(GetSetting("network.interface")->GetID());
1758 ifaceName = ifaceControl->GetLabel();
1759 CNetworkInterface* iface = g_application.getNetwork().GetInterfaceByName(ifaceName);
1761 // Update controls with information
1762 CGUISpinControlEx* pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.assignment")->GetID());
1763 if (pControl1) iAssignment = (NetworkAssignment) pControl1->GetValue();
1764 CGUIButtonControl* pControl2 = (CGUIButtonControl *)GetControl(GetSetting("network.ipaddress")->GetID());
1765 if (pControl2) sIPAddress = pControl2->GetLabel2();
1766 pControl2 = (CGUIButtonControl *)GetControl(GetSetting("network.subnet")->GetID());
1767 if (pControl2) sNetworkMask = pControl2->GetLabel2();
1768 pControl2 = (CGUIButtonControl *)GetControl(GetSetting("network.gateway")->GetID());
1769 if (pControl2) sDefaultGateway = pControl2->GetLabel2();
1770 pControl2 = (CGUIButtonControl *)GetControl(GetSetting("network.dns")->GetID());
1771 if (pControl2) sDns = pControl2->GetLabel2();
1772 pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.enc")->GetID());
1773 if (pControl1) iWirelessEnc = (EncMode) pControl1->GetValue();
1774 pControl2 = (CGUIButtonControl *)GetControl(GetSetting("network.essid")->GetID());
1775 if (pControl2) sWirelessNetwork = pControl2->GetLabel2();
1776 pControl2 = (CGUIButtonControl *)GetControl(GetSetting("network.key")->GetID());
1777 if (pControl2) sWirelessKey = pControl2->GetLabel2();
1779 CGUIDialogProgress* pDlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
1780 pDlgProgress->SetLine(0, "");
1781 pDlgProgress->SetLine(1, g_localizeStrings.Get(784));
1782 pDlgProgress->SetLine(2, "");
1783 pDlgProgress->StartModal();
1784 pDlgProgress->Progress();
1786 std::vector<CStdString> nameServers;
1787 nameServers.push_back(sDns);
1788 g_application.getNetwork().SetNameServers(nameServers);
1789 iface->SetSettings(iAssignment, sIPAddress, sNetworkMask, sDefaultGateway, sWirelessNetwork, sWirelessKey, iWirelessEnc);
1791 pDlgProgress->Close();
1793 if (iAssignment == NETWORK_DISABLED)
1794 CGUIDialogOK::ShowAndGetInput(0, 788, 0, 0);
1795 else if (iface->IsConnected())
1796 CGUIDialogOK::ShowAndGetInput(0, 785, 0, 0);
1798 CGUIDialogOK::ShowAndGetInput(0, 786, 0, 0);
1800 else if (strSetting.Equals("network.essid"))
1802 CGUIDialogAccessPoints *dialog = (CGUIDialogAccessPoints *)g_windowManager.GetWindow(WINDOW_DIALOG_ACCESS_POINTS);
1805 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting("network.interface")->GetID());
1806 dialog->SetInterfaceName(pControl->GetLabel());
1809 if (dialog->WasItemSelected())
1811 CGUIButtonControl* pControl2 = (CGUIButtonControl *)GetControl(GetSetting("network.essid")->GetID());
1812 if (pControl2) pControl2->SetLabel2(dialog->GetSelectedAccessPointEssId());
1813 pControl = (CGUISpinControlEx *)GetControl(GetSetting("network.enc")->GetID());
1814 if (pControl) pControl->SetValue(dialog->GetSelectedAccessPointEncMode());
1820 else if (strSetting.Equals("locale.timezonecountry"))
1822 CGUISpinControlEx *pControlCountry = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1823 CStdString country = pControlCountry->GetCurrentLabel();
1825 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting("locale.timezone")->GetID());
1827 vector<CStdString> timezones = g_timezone.GetTimezonesByCountry(country);
1828 for (unsigned int i=0; i < timezones.size(); i++)
1830 pControl->AddLabel(timezones[i], i);
1833 g_timezone.SetTimezone(pControl->GetLabel());
1834 g_guiSettings.SetString("locale.timezonecountry",pControlCountry->GetLabel().c_str());
1836 CGUISpinControlEx *tzControl = (CGUISpinControlEx *)GetControl(GetSetting("locale.timezone")->GetID());
1837 g_guiSettings.SetString("locale.timezone", tzControl->GetLabel().c_str());
1839 else if (strSetting.Equals("locale.timezone"))
1841 CGUISpinControlEx *tzControl = (CGUISpinControlEx *)GetControl(GetSetting("locale.timezone")->GetID());
1842 g_timezone.SetTimezone(tzControl->GetLabel());
1843 g_guiSettings.SetString("locale.timezone", tzControl->GetLabel().c_str());
1845 tzControl = (CGUISpinControlEx *)GetControl(GetSetting("locale.timezonecountry")->GetID());
1846 g_guiSettings.SetString("locale.timezonecountry", tzControl->GetLabel().c_str());
1849 else if (strSetting.Equals("lookandfeel.skinzoom"))
1851 g_windowManager.SendMessage(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_WINDOW_RESIZE);
1853 else if (strSetting.Equals("videolibrary.flattentvshows") ||
1854 strSetting.Equals("videolibrary.removeduplicates"))
1856 CUtil::DeleteVideoDatabaseDirectoryCache();
1862 void CGUIWindowSettingsCategory::FreeControls()
1864 // clear the category group
1865 CGUIControlGroupList *control = (CGUIControlGroupList *)GetControl(CATEGORY_GROUP_ID);
1868 control->FreeResources();
1869 control->ClearAll();
1871 m_vecSections.clear();
1872 FreeSettingsControls();
1875 void CGUIWindowSettingsCategory::FreeSettingsControls()
1877 // clear the settings group
1878 CGUIControlGroupList *control = (CGUIControlGroupList *)GetControl(SETTINGS_GROUP_ID);
1881 control->FreeResources();
1882 control->ClearAll();
1885 for(int i = 0; (size_t)i < m_vecSettings.size(); i++)
1887 delete m_vecSettings[i];
1889 m_vecSettings.clear();
1892 CGUIControl* CGUIWindowSettingsCategory::AddSetting(CSetting *pSetting, float width, int &iControlID)
1894 if (!pSetting->IsVisible()) return NULL; // not displayed in current session
1895 CBaseSettingControl *pSettingControl = NULL;
1896 CGUIControl *pControl = NULL;
1897 if (pSetting->GetControlType() == CHECKMARK_CONTROL)
1899 pControl = new CGUIRadioButtonControl(*m_pOriginalRadioButton);
1900 if (!pControl) return NULL;
1901 ((CGUIRadioButtonControl *)pControl)->SetLabel(g_localizeStrings.Get(pSetting->GetLabel()));
1902 pControl->SetWidth(width);
1903 pSettingControl = new CRadioButtonSettingControl((CGUIRadioButtonControl *)pControl, iControlID, pSetting);
1905 else if (pSetting->GetControlType() == SPIN_CONTROL_FLOAT || pSetting->GetControlType() == SPIN_CONTROL_INT_PLUS || pSetting->GetControlType() == SPIN_CONTROL_TEXT || pSetting->GetControlType() == SPIN_CONTROL_INT)
1907 pControl = new CGUISpinControlEx(*m_pOriginalSpin);
1908 if (!pControl) return NULL;
1909 pControl->SetWidth(width);
1910 ((CGUISpinControlEx *)pControl)->SetText(g_localizeStrings.Get(pSetting->GetLabel()));
1911 pSettingControl = new CSpinExSettingControl((CGUISpinControlEx *)pControl, iControlID, pSetting);
1913 else if (pSetting->GetControlType() == SEPARATOR_CONTROL && m_pOriginalImage)
1915 pControl = new CGUIImage(*m_pOriginalImage);
1916 if (!pControl) return NULL;
1917 pControl->SetWidth(width);
1918 pSettingControl = new CSeparatorSettingControl((CGUIImage *)pControl, iControlID, pSetting);
1920 else if (pSetting->GetControlType() == EDIT_CONTROL_INPUT ||
1921 pSetting->GetControlType() == EDIT_CONTROL_HIDDEN_INPUT ||
1922 pSetting->GetControlType() == EDIT_CONTROL_MD5_INPUT ||
1923 pSetting->GetControlType() == EDIT_CONTROL_NUMBER_INPUT ||
1924 pSetting->GetControlType() == EDIT_CONTROL_IP_INPUT)
1926 pControl = new CGUIEditControl(*m_pOriginalEdit);
1927 if (!pControl) return NULL;
1928 ((CGUIEditControl *)pControl)->SettingsCategorySetTextAlign(XBFONT_CENTER_Y);
1929 ((CGUIEditControl *)pControl)->SetLabel(g_localizeStrings.Get(pSetting->GetLabel()));
1930 pControl->SetWidth(width);
1931 pSettingControl = new CEditSettingControl((CGUIEditControl *)pControl, iControlID, pSetting);
1933 else if (pSetting->GetControlType() != SEPARATOR_CONTROL) // button control
1935 pControl = new CGUIButtonControl(*m_pOriginalButton);
1936 if (!pControl) return NULL;
1937 ((CGUIButtonControl *)pControl)->SettingsCategorySetTextAlign(XBFONT_CENTER_Y);
1938 ((CGUIButtonControl *)pControl)->SetLabel(g_localizeStrings.Get(pSetting->GetLabel()));
1939 pControl->SetWidth(width);
1940 pSettingControl = new CButtonSettingControl((CGUIButtonControl *)pControl, iControlID, pSetting);
1944 delete pSettingControl;
1947 pControl->SetID(iControlID++);
1948 pControl->SetVisible(true);
1949 CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(SETTINGS_GROUP_ID);
1952 pControl->AllocResources();
1953 group->AddControl(pControl);
1954 m_vecSettings.push_back(pSettingControl);
1959 void CGUIWindowSettingsCategory::FrameMove()
1961 // update realtime changeable stuff
1962 UpdateRealTimeSettings();
1964 if (m_delayedSetting && m_delayedTimer.GetElapsedMilliseconds() > 3000)
1965 { // we send a thread message so that it's processed the following frame (some settings won't
1966 // like being changed during Render())
1967 CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), GetID());
1968 g_windowManager.SendThreadMessage(message, GetID());
1969 m_delayedTimer.Stop();
1971 CGUIWindow::FrameMove();
1974 void CGUIWindowSettingsCategory::DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions)
1976 // update alpha status of current button
1977 bool bAlphaFaded = false;
1978 CGUIControl *control = GetFirstFocusableControl(CONTROL_START_BUTTONS + m_iSection);
1979 if (control && !control->HasFocus())
1981 if (control->GetControlType() == CGUIControl::GUICONTROL_BUTTON)
1983 control->SetFocus(true);
1984 ((CGUIButtonControl *)control)->SetAlpha(0x80);
1987 else if (control->GetControlType() == CGUIControl::GUICONTROL_TOGGLEBUTTON)
1989 control->SetFocus(true);
1990 ((CGUIButtonControl *)control)->SetSelected(true);
1994 CGUIWindow::DoProcess(currentTime, dirtyregions);
1997 control->SetFocus(false);
1998 if (control->GetControlType() == CGUIControl::GUICONTROL_BUTTON)
1999 ((CGUIButtonControl *)control)->SetAlpha(0xFF);
2001 ((CGUIButtonControl *)control)->SetSelected(false);
2005 void CGUIWindowSettingsCategory::Render()
2007 CGUIWindow::Render();
2008 // render the error message if necessary
2009 if (m_strErrorMessage.size())
2011 CGUIFont *pFont = g_fontManager.GetFont("font13");
2012 float fPosY = g_graphicsContext.GetHeight() * 0.8f;
2013 float fPosX = g_graphicsContext.GetWidth() * 0.5f;
2014 CGUITextLayout::DrawText(pFont, fPosX, fPosY, 0xffffffff, 0, m_strErrorMessage, XBFONT_CENTER_X);
2018 void CGUIWindowSettingsCategory::CheckNetworkSettings()
2020 if (!g_application.IsStandAlone())
2023 // check if our network needs restarting (requires a reset, so check well!)
2024 if (m_iNetworkAssignment == -1)
2026 // nothing to do here, folks - move along.
2029 // we need a reset if:
2030 // 1. The Network Assignment has changed OR
2031 // 2. The Network Assignment is STATIC and one of the network fields have changed
2032 if (m_iNetworkAssignment != g_guiSettings.GetInt("network.assignment") ||
2033 (m_iNetworkAssignment == NETWORK_STATIC && (
2034 m_strNetworkIPAddress != g_guiSettings.GetString("network.ipaddress") ||
2035 m_strNetworkSubnet != g_guiSettings.GetString("network.subnet") ||
2036 m_strNetworkGateway != g_guiSettings.GetString("network.gateway") ||
2037 m_strNetworkDNS != g_guiSettings.GetString("network.dns"))))
2039 /* // our network settings have changed - we should prompt the user to reset XBMC
2040 if (CGUIDialogYesNo::ShowAndGetInput(14038, 14039, 14040, 0))
2043 g_application.getApplicationMessenger().RestartApp();
2044 // Todo: aquire new network settings without restart app!
2048 // update our settings variables
2049 m_iNetworkAssignment = g_guiSettings.GetInt("network.assignment");
2050 m_strNetworkIPAddress = g_guiSettings.GetString("network.ipaddress");
2051 m_strNetworkSubnet = g_guiSettings.GetString("network.subnet");
2052 m_strNetworkGateway = g_guiSettings.GetString("network.gateway");
2053 m_strNetworkDNS = g_guiSettings.GetString("network.dns");
2056 /* g_guiSettings.SetInt("network.assignment", m_iNetworkAssignment);
2057 g_guiSettings.SetString("network.ipaddress", m_strNetworkIPAddress);
2058 g_guiSettings.SetString("network.subnet", m_strNetworkSubnet);
2059 g_guiSettings.SetString("network.gateway", m_strNetworkGateway);
2060 g_guiSettings.SetString("network.dns", m_strNetworkDNS);*/
2064 void CGUIWindowSettingsCategory::FillInSubtitleHeights(CSetting *pSetting, CGUISpinControlEx *pControl)
2066 CSettingInt *pSettingInt = (CSettingInt*)pSetting;
2067 pControl->SetType(SPIN_CONTROL_TYPE_TEXT);
2069 if (CUtil::IsUsingTTFSubtitles())
2070 { // easy - just fill as per usual
2071 CStdString strLabel;
2072 for (int i = pSettingInt->m_iMin; i <= pSettingInt->m_iMax; i += pSettingInt->m_iStep)
2074 if (pSettingInt->m_iFormat > -1)
2076 CStdString strFormat = g_localizeStrings.Get(pSettingInt->m_iFormat);
2077 strLabel.Format(strFormat, i);
2080 strLabel.Format(pSettingInt->m_strFormat, i);
2081 pControl->AddLabel(strLabel, i);
2083 pControl->SetValue(pSettingInt->GetData());
2087 void CGUIWindowSettingsCategory::FillInSubtitleFonts(CSetting *pSetting)
2089 CSettingString *pSettingString = (CSettingString*)pSetting;
2090 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID());
2091 pControl->SetType(SPIN_CONTROL_TYPE_TEXT);
2093 int iCurrentFont = 0;
2098 CFileItemList items;
2099 if (CDirectory::GetDirectory("special://xbmc/media/Fonts/", items))
2101 for (int i = 0; i < items.Size(); ++i)
2103 CFileItemPtr pItem = items[i];
2105 if (!pItem->m_bIsFolder)
2108 if ( !URIUtils::GetExtension(pItem->GetLabel()).Equals(".ttf") ) continue;
2109 if (pItem->GetLabel().Equals(pSettingString->GetData(), false))
2110 iCurrentFont = iFont;
2112 pControl->AddLabel(pItem->GetLabel(), iFont++);
2118 pControl->SetValue(iCurrentFont);
2121 void CGUIWindowSettingsCategory::FillInSkinFonts(CSetting *pSetting)
2123 CBaseSettingControl *setting = GetSetting(pSetting->GetSetting());
2124 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(setting->GetID());
2125 pControl->SetType(SPIN_CONTROL_TYPE_TEXT);
2127 setting->SetDelayed();
2129 m_SkinFontSetIDs.clear();
2130 int iSkinFontSet = 0;
2132 CStdString strPath = g_SkinInfo->GetSkinPath("Font.xml");
2134 TiXmlDocument xmlDoc;
2135 if (!xmlDoc.LoadFile(strPath))
2137 CLog::Log(LOGERROR, "Couldn't load %s", strPath.c_str());
2141 TiXmlElement* pRootElement = xmlDoc.RootElement();
2143 CStdString strValue = pRootElement->Value();
2144 if (strValue != CStdString("fonts"))
2146 CLog::Log(LOGERROR, "file %s doesnt start with <fonts>", strPath.c_str());
2150 const TiXmlNode *pChild = pRootElement->FirstChild();
2151 strValue = pChild->Value();
2152 if (strValue == "fontset")
2156 strValue = pChild->Value();
2157 if (strValue == "fontset")
2159 const char* idAttr = ((TiXmlElement*) pChild)->Attribute("id");
2160 const char* idLocAttr = ((TiXmlElement*) pChild)->Attribute("idloc");
2161 const char* unicodeAttr = ((TiXmlElement*) pChild)->Attribute("unicode");
2163 bool isUnicode=(unicodeAttr && stricmp(unicodeAttr, "true") == 0);
2165 bool isAllowed=true;
2166 if (g_langInfo.ForceUnicodeFont() && !isUnicode)
2169 if (idAttr != NULL && isAllowed)
2173 pControl->AddLabel(g_localizeStrings.Get(atoi(idLocAttr)), iSkinFontSet);
2174 m_SkinFontSetIDs[g_localizeStrings.Get(atoi(idLocAttr))] = idAttr;
2178 pControl->AddLabel(idAttr, iSkinFontSet);
2179 m_SkinFontSetIDs[idAttr] = idAttr;
2181 if (strcmpi(idAttr, g_guiSettings.GetString("lookandfeel.font").c_str()) == 0)
2182 pControl->SetValue(iSkinFontSet);
2186 pChild = pChild->NextSibling();
2192 // Since no fontset is defined, there is no selection of a fontset, so disable the component
2193 pControl->AddLabel(g_localizeStrings.Get(13278), 1);
2194 pControl->SetValue(1);
2195 pControl->SetEnabled(false);
2199 void CGUIWindowSettingsCategory::FillInSoundSkins(CSetting *pSetting)
2201 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID());
2202 pControl->SetType(SPIN_CONTROL_TYPE_TEXT);
2204 pControl->SetShowRange(true);
2207 CFileItemList items;
2208 CDirectory::GetDirectory("special://xbmc/sounds/", items);
2209 CDirectory::GetDirectory("special://home/sounds/", items);
2211 int iCurrentSoundSkin = 0;
2213 vector<CStdString> vecSoundSkins;
2215 for (i = 0; i < items.Size(); ++i)
2217 CFileItemPtr pItem = items[i];
2218 if (pItem->m_bIsFolder)
2220 if (strcmpi(pItem->GetLabel().c_str(), ".svn") == 0) continue;
2221 if (strcmpi(pItem->GetLabel().c_str(), "fonts") == 0) continue;
2222 if (strcmpi(pItem->GetLabel().c_str(), "media") == 0) continue;
2223 vecSoundSkins.push_back(pItem->GetLabel());
2227 pControl->AddLabel(g_localizeStrings.Get(474), iSoundSkin++); // Off
2228 pControl->AddLabel(g_localizeStrings.Get(15109), iSoundSkin++); // Skin Default
2230 if (g_guiSettings.GetString("lookandfeel.soundskin")=="SKINDEFAULT")
2231 iCurrentSoundSkin=1;
2233 sort(vecSoundSkins.begin(), vecSoundSkins.end(), sortstringbyname());
2234 for (i = 0; i < (int) vecSoundSkins.size(); ++i)
2236 CStdString strSkin = vecSoundSkins[i];
2237 if (strcmpi(strSkin.c_str(), g_guiSettings.GetString("lookandfeel.soundskin").c_str()) == 0)
2239 iCurrentSoundSkin = iSoundSkin;
2241 pControl->AddLabel(strSkin, iSoundSkin++);
2243 pControl->SetValue(iCurrentSoundSkin);
2247 void CGUIWindowSettingsCategory::FillInCharSets(CSetting *pSetting)
2249 CSettingString *pSettingString = (CSettingString*)pSetting;
2250 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID());
2251 pControl->SetType(SPIN_CONTROL_TYPE_TEXT);
2253 int iCurrentCharset = 0;
2254 vector<CStdString> vecCharsets = g_charsetConverter.getCharsetLabels();
2256 CStdString strCurrentCharsetLabel="DEFAULT";
2257 if (pSettingString->GetData()!="DEFAULT")
2258 strCurrentCharsetLabel = g_charsetConverter.getCharsetLabelByName(pSettingString->GetData());
2260 sort(vecCharsets.begin(), vecCharsets.end(), sortstringbyname());
2262 vecCharsets.insert(vecCharsets.begin(), g_localizeStrings.Get(13278)); // "Default"
2264 bool bIsAuto=(pSettingString->GetData()=="DEFAULT");
2266 for (int i = 0; i < (int) vecCharsets.size(); ++i)
2268 CStdString strCharsetLabel = vecCharsets[i];
2270 if (!bIsAuto && strCharsetLabel == strCurrentCharsetLabel)
2271 iCurrentCharset = i;
2273 pControl->AddLabel(strCharsetLabel, i);
2276 pControl->SetValue(iCurrentCharset);
2279 DisplayMode CGUIWindowSettingsCategory::FillInScreens(CStdString strSetting, RESOLUTION res)
2281 CBaseSettingControl *control = GetSetting(strSetting);
2282 control->SetDelayed();
2283 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(control->GetID());
2286 CStdString strScreen;
2287 if (g_advancedSettings.m_canWindowed)
2288 pControl->AddLabel(g_localizeStrings.Get(242), -1);
2290 for (int idx = 0; idx < g_Windowing.GetNumScreens(); idx++)
2292 strScreen.Format(g_localizeStrings.Get(241), g_settings.m_ResInfo[RES_DESKTOP + idx].iScreen + 1);
2293 pControl->AddLabel(strScreen, g_settings.m_ResInfo[RES_DESKTOP + idx].iScreen);
2298 if (res == RES_WINDOW)
2301 mode = g_settings.m_ResInfo[res].iScreen;
2303 pControl->SetValue(mode);
2304 g_guiSettings.SetInt("videoscreen.screen", mode);
2308 void CGUIWindowSettingsCategory::FillInResolutions(CStdString strSetting, DisplayMode mode, RESOLUTION res, bool UserChange)
2310 CBaseSettingControl *control = GetSetting(strSetting);
2311 control->SetDelayed();
2312 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(control->GetID());
2316 RESOLUTION spinres = RES_INVALID; // index of the resolution in the spinner that has same screen/width/height as res
2318 if (mode == DM_WINDOWED)
2320 pControl->AddLabel(g_localizeStrings.Get(242), RES_WINDOW);
2321 spinres = RES_WINDOW;
2325 vector<RESOLUTION_WHR> resolutions = g_Windowing.ScreenResolutions(mode);
2327 for (unsigned int idx = 0; idx < resolutions.size(); idx++)
2330 strRes.Format("%dx%d", resolutions[idx].width, resolutions[idx].height);
2331 pControl->AddLabel(strRes, resolutions[idx].ResInfo_Index);
2333 RESOLUTION_INFO res1 = g_settings.m_ResInfo[res];
2334 RESOLUTION_INFO res2 = g_settings.m_ResInfo[resolutions[idx].ResInfo_Index];
2335 if (res1.iScreen == res2.iScreen && res1.iWidth == res2.iWidth && res1.iHeight == res2.iHeight)
2336 spinres = (RESOLUTION) resolutions[idx].ResInfo_Index;
2342 // Auto-select the windowed or desktop resolution of the screen
2343 int autoresolution = RES_DESKTOP;
2344 if (mode == DM_WINDOWED)
2346 autoresolution = RES_WINDOW;
2350 for (int idx=0; idx < g_Windowing.GetNumScreens(); idx++)
2351 if (g_settings.m_ResInfo[RES_DESKTOP + idx].iScreen == mode)
2353 autoresolution = RES_DESKTOP + idx;
2357 pControl->SetValue(autoresolution);
2360 FillInRefreshRates("videoscreen.screenmode", (RESOLUTION) autoresolution, true);
2364 // select the entry equivalent to the resolution passed by the res parameter
2365 pControl->SetValue(spinres);
2369 void CGUIWindowSettingsCategory::FillInRefreshRates(CStdString strSetting, RESOLUTION res, bool UserChange)
2371 // The only meaningful parts of res here are iScreen, iWidth, iHeight
2373 vector<REFRESHRATE> refreshrates;
2374 if (res > RES_WINDOW)
2375 refreshrates = g_Windowing.RefreshRates(g_settings.m_ResInfo[res].iScreen, g_settings.m_ResInfo[res].iWidth, g_settings.m_ResInfo[res].iHeight);
2377 // The control setting doesn't exist when not in standalone mode, don't manipulate it
2378 CBaseSettingControl *control = GetSetting(strSetting);
2379 CGUISpinControlEx *pControl= NULL;
2384 control->SetDelayed();
2385 pControl = (CGUISpinControlEx *)GetControl(control->GetID());
2388 if (res == RES_WINDOW)
2390 pControl->AddLabel(g_localizeStrings.Get(242), RES_WINDOW);
2394 for (unsigned int idx = 0; idx < refreshrates.size(); idx++)
2397 strRR.Format("%.02f%s", refreshrates[idx].RefreshRate, refreshrates[idx].Interlaced ? "i" : "");
2398 pControl->AddLabel(strRR, refreshrates[idx].ResInfo_Index);
2406 RESOLUTION newresolution;
2407 if (res == RES_WINDOW)
2408 newresolution = RES_WINDOW;
2410 newresolution = (RESOLUTION) g_Windowing.DefaultRefreshRate(g_settings.m_ResInfo[res].iScreen, refreshrates).ResInfo_Index;
2413 pControl->SetValue(newresolution);
2415 OnRefreshRateChanged(newresolution);
2420 pControl->SetValue(res);
2424 void CGUIWindowSettingsCategory::OnRefreshRateChanged(RESOLUTION nextRes)
2426 RESOLUTION lastRes = g_graphicsContext.GetVideoResolution();
2427 bool cancelled = false;
2429 g_guiSettings.SetResolution(nextRes);
2430 g_graphicsContext.SetVideoResolution(nextRes);
2432 if (!CGUIDialogYesNo::ShowAndGetInput(13110, 13111, 20022, 20022, -1, -1, cancelled, 10000))
2434 g_guiSettings.SetResolution(lastRes);
2435 g_graphicsContext.SetVideoResolution(lastRes);
2437 DisplayMode mode = FillInScreens("videoscreen.screen", lastRes);
2438 FillInResolutions("videoscreen.resolution", mode, lastRes, false);
2439 FillInRefreshRates("videoscreen.screenmode", lastRes, false);
2443 void CGUIWindowSettingsCategory::FillInLanguages(CSetting *pSetting)
2445 CSettingString *pSettingString = (CSettingString *)pSetting;
2446 CBaseSettingControl *setting = GetSetting(pSetting->GetSetting());
2447 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(setting->GetID());
2448 setting->SetDelayed();
2452 CFileItemList items;
2453 CDirectory::GetDirectory("special://xbmc/language/", items);
2455 int iCurrentLang = 0;
2457 vector<CStdString> vecLanguage;
2458 for (int i = 0; i < items.Size(); ++i)
2460 CFileItemPtr pItem = items[i];
2461 if (pItem->m_bIsFolder)
2463 if (strcmpi(pItem->GetLabel().c_str(), ".svn") == 0) continue;
2464 if (strcmpi(pItem->GetLabel().c_str(), "fonts") == 0) continue;
2465 if (strcmpi(pItem->GetLabel().c_str(), "media") == 0) continue;
2466 vecLanguage.push_back(pItem->GetLabel());
2470 sort(vecLanguage.begin(), vecLanguage.end(), sortstringbyname());
2471 for (unsigned int i = 0; i < vecLanguage.size(); ++i)
2473 CStdString strLanguage = vecLanguage[i];
2474 if (strcmpi(strLanguage.c_str(), pSettingString->GetData().c_str()) == 0)
2475 iCurrentLang = iLanguage;
2476 pControl->AddLabel(strLanguage, iLanguage++);
2479 pControl->SetValue(iCurrentLang);
2482 void CGUIWindowSettingsCategory::FillInRegions(CSetting *pSetting)
2484 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID());
2485 pControl->SetType(SPIN_CONTROL_TYPE_TEXT);
2488 int iCurrentRegion=0;
2489 CStdStringArray regions;
2490 g_langInfo.GetRegionNames(regions);
2492 CStdString strCurrentRegion=g_langInfo.GetCurrentRegion();
2494 sort(regions.begin(), regions.end(), sortstringbyname());
2496 for (int i = 0; i < (int) regions.size(); ++i)
2498 const CStdString& strRegion = regions[i];
2500 if (strRegion == strCurrentRegion)
2503 pControl->AddLabel(strRegion, i);
2506 pControl->SetValue(iCurrentRegion);
2509 CBaseSettingControl *CGUIWindowSettingsCategory::GetSetting(const CStdString &strSetting)
2511 for (unsigned int i = 0; i < m_vecSettings.size(); i++)
2513 if (m_vecSettings[i]->GetSetting()->GetSetting() == strSetting)
2514 return m_vecSettings[i];
2519 void CGUIWindowSettingsCategory::FillInSkinThemes(CSetting *pSetting)
2521 // There is a default theme (just Textures.xpr/xbt)
2522 // any other *.xpr|*.xbt files are additional themes on top of this one.
2523 CSettingString *pSettingString = (CSettingString *)pSetting;
2524 CBaseSettingControl *setting = GetSetting(pSetting->GetSetting());
2525 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(setting->GetID());
2526 CStdString strSettingString = g_guiSettings.GetString("lookandfeel.skintheme");
2527 setting->SetDelayed();
2529 // Clear and add. the Default Label
2531 pControl->SetShowRange(true);
2532 pControl->AddLabel(g_localizeStrings.Get(15109), 0); // "SKINDEFAULT" The standard Textures.xpr/xbt will be used
2534 CStdString strDefaultTheme = pSettingString->GetData();
2536 // Search for Themes in the Current skin!
2537 vector<CStdString> vecTheme;
2538 CUtil::GetSkinThemes(vecTheme);
2540 // Remove the extension from the current Theme (backward compat)
2541 URIUtils::RemoveExtension(strSettingString);
2543 // Sort the Themes for GUI and list them
2544 int iCurrentTheme = 0;
2545 for (int i = 0; i < (int) vecTheme.size(); ++i)
2547 CStdString strTheme = vecTheme[i];
2548 // Is the Current Theme our Used Theme! If yes set the ID!
2549 if (strTheme.CompareNoCase(strSettingString) == 0 )
2550 iCurrentTheme = i + 1; // 1: #of Predefined Theme [Label]
2551 pControl->AddLabel(strTheme, i + 1);
2553 // Set the Choosen Theme
2554 pControl->SetValue(iCurrentTheme);
2557 void CGUIWindowSettingsCategory::FillInSkinColors(CSetting *pSetting)
2559 // There is a default theme (just defaults.xml)
2560 // any other *.xml files are additional color themes on top of this one.
2561 CBaseSettingControl *setting = GetSetting(pSetting->GetSetting());
2562 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(setting->GetID());
2563 CStdString strSettingString = g_guiSettings.GetString("lookandfeel.skincolors");
2564 setting->SetDelayed();
2566 // Clear and add. the Default Label
2568 pControl->SetShowRange(true);
2569 pControl->AddLabel(g_localizeStrings.Get(15109), 0); // "SKINDEFAULT"! The standard defaults.xml will be used!
2571 // Search for colors in the Current skin!
2572 vector<CStdString> vecColors;
2575 URIUtils::AddFileToFolder(g_SkinInfo->Path(),"colors",strPath);
2577 CFileItemList items;
2578 CDirectory::GetDirectory(PTH_IC(strPath), items, ".xml");
2579 // Search for Themes in the Current skin!
2580 for (int i = 0; i < items.Size(); ++i)
2582 CFileItemPtr pItem = items[i];
2583 if (!pItem->m_bIsFolder && pItem->GetLabel().CompareNoCase("defaults.xml") != 0)
2584 { // not the default one
2585 CStdString strLabel = pItem->GetLabel();
2586 vecColors.push_back(strLabel.Mid(0, strLabel.size() - 4));
2589 sort(vecColors.begin(), vecColors.end(), sortstringbyname());
2591 // Remove the .xml extension from the Themes
2592 if (URIUtils::GetExtension(strSettingString) == ".xml")
2593 URIUtils::RemoveExtension(strSettingString);
2595 int iCurrentColor = 0;
2596 for (int i = 0; i < (int) vecColors.size(); ++i)
2598 CStdString strColor = vecColors[i];
2599 // Is the Current Theme our Used Theme! If yes set the ID!
2600 if (strColor.CompareNoCase(strSettingString) == 0 )
2601 iCurrentColor = i + 1; // 1: #of Predefined Theme [Label]
2602 pControl->AddLabel(strColor, i + 1);
2604 // Set the Choosen Theme
2605 pControl->SetValue(iCurrentColor);
2608 void CGUIWindowSettingsCategory::FillInStartupWindow(CSetting *pSetting)
2610 CSettingInt *pSettingInt = (CSettingInt*)pSetting;
2611 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID());
2614 const vector<CSkinInfo::CStartupWindow> &startupWindows = g_SkinInfo->GetStartupWindows();
2616 // TODO: How should we localize this?
2617 // In the long run there is no way to do it really without the skin having some
2618 // translation information built in to it, which isn't really feasible.
2620 // Alternatively we could lookup the strings in the english strings file to get
2621 // their id and then get the string from that
2623 // easier would be to have the skinner use the "name" as the label number.
2625 // eg <window id="0">513</window>
2627 bool currentSettingFound(false);
2628 for (vector<CSkinInfo::CStartupWindow>::const_iterator it = startupWindows.begin(); it != startupWindows.end(); it++)
2630 CStdString windowName((*it).m_name);
2631 if (StringUtils::IsNaturalNumber(windowName))
2632 windowName = g_localizeStrings.Get(atoi(windowName.c_str()));
2633 int windowID((*it).m_id);
2634 pControl->AddLabel(windowName, windowID);
2635 if (pSettingInt->GetData() == windowID)
2636 currentSettingFound = true;
2639 // ok, now check whether our current option is one of these
2640 // and set it's value
2641 if (!currentSettingFound)
2642 { // nope - set it to the "default" option - the first one
2643 pSettingInt->SetData(startupWindows[0].m_id);
2645 pControl->SetValue(pSettingInt->GetData());
2648 void CGUIWindowSettingsCategory::OnInitWindow()
2650 if (g_application.IsStandAlone())
2653 m_iNetworkAssignment = g_guiSettings.GetInt("network.assignment");
2654 m_strNetworkIPAddress = g_guiSettings.GetString("network.ipaddress");
2655 m_strNetworkSubnet = g_guiSettings.GetString("network.subnet");
2656 m_strNetworkGateway = g_guiSettings.GetString("network.gateway");
2657 m_strNetworkDNS = g_guiSettings.GetString("network.dns");
2660 m_strOldTrackFormat = g_guiSettings.GetString("musicfiles.trackformat");
2661 m_strOldTrackFormatRight = g_guiSettings.GetString("musicfiles.trackformatright");
2663 CGUIWindow::OnInitWindow();
2666 void CGUIWindowSettingsCategory::FillInViewModes(CSetting *pSetting, int windowID)
2668 CSettingInt *pSettingInt = (CSettingInt*)pSetting;
2669 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID());
2670 pControl->AddLabel("Auto", DEFAULT_VIEW_AUTO);
2673 CGUIWindow *window = g_windowManager.GetWindow(windowID);
2676 window->Initialize();
2677 for (int i = 50; i < 60; i++)
2679 CGUIBaseContainer *control = (CGUIBaseContainer *)window->GetControl(i);
2682 int type = (control->GetType() << 16) | i;
2683 pControl->AddLabel(control->GetLabel(), type);
2684 if (type == pSettingInt->GetData())
2686 else if ((type >> 16) == (pSettingInt->GetData() >> 16))
2693 pSettingInt->SetData(foundType ? foundType : (DEFAULT_VIEW_AUTO));
2694 pControl->SetValue(pSettingInt->GetData());
2697 void CGUIWindowSettingsCategory::FillInSortMethods(CSetting *pSetting, int windowID)
2699 CSettingInt *pSettingInt = (CSettingInt*)pSetting;
2700 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID());
2701 CFileItemList items("C:");
2702 CGUIViewState *state = CGUIViewState::GetViewState(windowID, items);
2706 vector< pair<int,int> > sortMethods;
2707 state->GetSortMethods(sortMethods);
2708 for (unsigned int i = 0; i < sortMethods.size(); i++)
2710 pControl->AddLabel(g_localizeStrings.Get(sortMethods[i].second), sortMethods[i].first);
2711 if (sortMethods[i].first == pSettingInt->GetData())
2714 if (!found && sortMethods.size())
2715 pSettingInt->SetData(sortMethods[0].first);
2717 pControl->SetValue(pSettingInt->GetData());
2721 void CGUIWindowSettingsCategory::FillInNetworkInterfaces(CSetting *pSetting, float groupWidth, int &iControlID)
2723 CGUISpinControlEx *pControl = (CGUISpinControlEx *)AddSetting(pSetting, groupWidth, iControlID);
2726 // query list of interfaces
2727 vector<CStdString> vecInterfaces;
2728 std::vector<CNetworkInterface*>& ifaces = g_application.getNetwork().GetInterfaceList();
2729 std::vector<CNetworkInterface*>::const_iterator iter = ifaces.begin();
2730 while (iter != ifaces.end())
2732 CNetworkInterface* iface = *iter;
2733 vecInterfaces.push_back(iface->GetName());
2736 sort(vecInterfaces.begin(), vecInterfaces.end(), sortstringbyname());
2739 for (unsigned int i = 0; i < vecInterfaces.size(); ++i)
2740 pControl->AddLabel(vecInterfaces[i], iInterface++);
2743 void CGUIWindowSettingsCategory::FillInAudioDevices(CSetting* pSetting, bool Passthrough)
2745 #if defined(__APPLE__)
2746 #if defined(__arm__)
2749 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID());
2752 IOSCoreAudioDeviceList deviceList;
2753 CIOSCoreAudioHardware::GetOutputDevices(&deviceList);
2755 // This will cause FindAudioDevice to fall back to the system default as configured in 'System Preferences'
2756 if (CIOSCoreAudioHardware::GetDefaultOutputDevice())
2757 pControl->AddLabel("Default Output Device", 0);
2759 int activeDevice = 0;
2760 CStdString deviceName;
2761 for (int i = pControl->GetMaximum(); !deviceList.empty(); i++)
2763 CIOSCoreAudioDevice device(deviceList.front());
2764 pControl->AddLabel(device.GetName(deviceName), i);
2767 if (g_guiSettings.GetString("audiooutput.audiodevice").Equals(deviceName))
2770 deviceList.pop_front();
2772 pControl->SetValue(activeDevice);
2776 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID());
2779 CoreAudioDeviceList deviceList;
2780 CCoreAudioHardware::GetOutputDevices(&deviceList);
2782 // This will cause FindAudioDevice to fall back to the system default as configured in 'System Preferences'
2783 if (CCoreAudioHardware::GetDefaultOutputDevice())
2784 pControl->AddLabel("Default Output Device", 0);
2786 int activeDevice = 0;
2787 CStdString deviceName;
2788 for (int i = pControl->GetMaximum(); !deviceList.empty(); i++)
2790 CCoreAudioDevice device(deviceList.front());
2791 pControl->AddLabel(device.GetName(deviceName), i);
2793 if (g_guiSettings.GetString("audiooutput.audiodevice").Equals(deviceName))
2794 activeDevice = i; // Tag this one
2796 deviceList.pop_front();
2798 pControl->SetValue(activeDevice);
2801 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID());
2804 CStdString currentDevice = Passthrough ? g_guiSettings.GetString("audiooutput.passthroughdevice") : g_guiSettings.GetString("audiooutput.audiodevice");
2808 m_DigitalAudioSinkMap.clear();
2809 m_DigitalAudioSinkMap["Error - no devices found"] = "null:";
2810 m_DigitalAudioSinkMap[g_localizeStrings.Get(636)] = "custom";
2814 m_AnalogAudioSinkMap.clear();
2815 m_AnalogAudioSinkMap["Error - no devices found"] = "null:";
2816 m_AnalogAudioSinkMap[g_localizeStrings.Get(636)] = "custom";
2819 int numberSinks = 0;
2821 int selectedValue = -1;
2822 AudioSinkList sinkList;
2823 CAudioRendererFactory::EnumerateAudioSinks(sinkList, Passthrough);
2824 if (sinkList.size()==0)
2826 pControl->AddLabel("Error - no devices found", 0);
2832 AudioSinkList::const_iterator iter = sinkList.begin();
2833 for (int i=0; iter != sinkList.end(); iter++)
2835 CStdString label = (*iter).first;
2836 CStdString sink = (*iter).second;
2837 pControl->AddLabel(label.c_str(), i);
2839 if (currentDevice.Equals(sink))
2843 m_DigitalAudioSinkMap[label] = sink;
2845 m_AnalogAudioSinkMap[label] = sink;
2850 numberSinks = sinkList.size();
2854 if (currentDevice.Equals("custom"))
2855 selectedValue = numberSinks;
2857 pControl->AddLabel(g_localizeStrings.Get(636), numberSinks++);
2860 if (selectedValue < 0)
2862 CLog::Log(LOGWARNING, "Failed to find previously selected audio sink");
2863 pControl->AddLabel(currentDevice, numberSinks);
2864 pControl->SetValue(numberSinks);
2867 pControl->SetValue(selectedValue);
2871 void CGUIWindowSettingsCategory::NetworkInterfaceChanged(void)
2875 NetworkAssignment iAssignment;
2876 CStdString sIPAddress;
2877 CStdString sNetworkMask;
2878 CStdString sDefaultGateway;
2879 CStdString sWirelessNetwork;
2880 CStdString sWirelessKey;
2881 EncMode iWirelessEnc;
2883 CStdString ifaceName;
2885 // Get network information
2886 CGUISpinControlEx *ifaceControl = (CGUISpinControlEx *)GetControl(GetSetting("network.interface")->GetID());
2887 ifaceName = ifaceControl->GetLabel();
2888 CNetworkInterface* iface = g_application.getNetwork().GetInterfaceByName(ifaceName);
2889 iface->GetSettings(iAssignment, sIPAddress, sNetworkMask, sDefaultGateway, sWirelessNetwork, sWirelessKey, iWirelessEnc);
2890 bIsWireless = iface->IsWireless();
2893 std::vector<CStdString> dnss = g_application.getNetwork().GetNameServers();
2894 if (dnss.size() >= 1)
2897 // Update controls with information
2898 CGUISpinControlEx* pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.assignment")->GetID());
2899 if (pControl1) pControl1->SetValue(iAssignment);
2900 GetSetting("network.dns")->GetSetting()->FromString(dns);
2901 if (iAssignment == NETWORK_STATIC || iAssignment == NETWORK_DISABLED)
2903 GetSetting("network.ipaddress")->GetSetting()->FromString(sIPAddress);
2904 GetSetting("network.subnet")->GetSetting()->FromString(sNetworkMask);
2905 GetSetting("network.gateway")->GetSetting()->FromString(sDefaultGateway);
2909 GetSetting("network.ipaddress")->GetSetting()->FromString(iface->GetCurrentIPAddress());
2910 GetSetting("network.subnet")->GetSetting()->FromString(iface->GetCurrentNetmask());
2911 GetSetting("network.gateway")->GetSetting()->FromString(iface->GetCurrentDefaultGateway());
2914 pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.enc")->GetID());
2915 if (pControl1) pControl1->SetValue(iWirelessEnc);
2919 GetSetting("network.essid")->GetSetting()->FromString(sWirelessNetwork);
2920 GetSetting("network.key")->GetSetting()->FromString(sWirelessKey);
2924 GetSetting("network.essid")->GetSetting()->FromString("");
2925 GetSetting("network.key")->GetSetting()->FromString("");
2929 void CGUIWindowSettingsCategory::ValidatePortNumber(CBaseSettingControl* pSettingControl, const CStdString& userPort, const CStdString& privPort, bool listening/*=true*/)
2931 CSettingString *pSetting = (CSettingString *)pSettingControl->GetSetting();
2932 // check that it's a valid port
2933 int port = atoi(pSetting->GetData().c_str());
2935 if (listening && geteuid() != 0 && (port < 1024 || port > 65535))
2937 CGUIDialogOK::ShowAndGetInput(257, 850, 852, -1);
2938 pSetting->SetData(userPort.c_str());
2942 if (port <= 0 || port > 65535)
2944 CGUIDialogOK::ShowAndGetInput(257, 850, 851, -1);
2945 pSetting->SetData(privPort.c_str());