2 * Copyright (C) 2005-2012 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, see
17 * <http://www.gnu.org/licenses/>.
22 #include "GUIUserMessages.h"
23 #include "GUIWindowSettingsCategory.h"
24 #include "Application.h"
25 #include "ApplicationMessenger.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 "network/libscrobbler/lastfmscrobbler.h"
45 #include "network/libscrobbler/librefmscrobbler.h"
46 #include "GUIPassword.h"
47 #include "GUIInfoManager.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/GUIDialogYesNo.h"
55 #include "dialogs/GUIDialogOK.h"
56 #include "dialogs/GUIDialogProgress.h"
57 #include "dialogs/GUIDialogKaiToast.h"
58 #include "addons/Visualisation.h"
59 #include "addons/AddonManager.h"
60 #include "addons/AddonInstaller.h"
61 #include "storage/MediaManager.h"
62 #include "network/Network.h"
63 #include "guilib/GUIControlGroupList.h"
64 #include "guilib/GUIWindowManager.h"
65 #include "guilib/GUIFontManager.h"
66 #include "cores/AudioEngine/AEFactory.h"
68 #include "LinuxTimezone.h"
71 #include "HALManager.h"
74 #if defined(TARGET_DARWIN_OSX)
75 #include "XBMCHelper.h"
77 #include "network/GUIDialogAccessPoints.h"
78 #include "filesystem/Directory.h"
81 #include "guilib/GUIToggleButtonControl.h"
82 #include "filesystem/SpecialProtocol.h"
84 #include "network/Zeroconf.h"
85 #include "peripherals/Peripherals.h"
86 #include "peripherals/dialogs/GUIDialogPeripheralManager.h"
87 #include "peripherals/devices/PeripheralImon.h"
90 #include "WIN32Util.h"
94 #include "AdvancedSettings.h"
95 #include "input/MouseStat.h"
96 #if defined(TARGET_WINDOWS)
97 #include "input/windows/WINJoystick.h"
98 #elif defined(HAS_SDL_JOYSTICK)
99 #include "input/SDLJoystick.h"
101 #include "guilib/LocalizeStrings.h"
102 #include "LangInfo.h"
103 #include "utils/StringUtils.h"
104 #include "utils/URIUtils.h"
105 #include "utils/SystemInfo.h"
106 #include "windowing/WindowingFactory.h"
107 #include "pvr/dialogs/GUIDialogPVRChannelManager.h"
108 #include "pvr/PVRManager.h"
109 #include "pvr/addons/PVRClients.h"
111 #if defined(HAVE_LIBCRYSTALHD)
112 #include "cores/dvdplayer/DVDCodecs/Video/CrystalHD.h"
115 #if defined(HAS_AIRPLAY)
116 #include "network/AirPlayServer.h"
119 #if defined(HAS_WEB_SERVER)
120 #include "network/WebServer.h"
124 using namespace XFILE;
125 using namespace ADDON;
127 using namespace PERIPHERALS;
129 #define CONTROL_GROUP_BUTTONS 0
130 #define CONTROL_GROUP_SETTINGS 1
131 #define CONTROL_SETTINGS_LABEL 2
132 #define CATEGORY_GROUP_ID 3
133 #define SETTINGS_GROUP_ID 5
134 #define CONTROL_DEFAULT_BUTTON 7
135 #define CONTROL_DEFAULT_RADIOBUTTON 8
136 #define CONTROL_DEFAULT_SPIN 9
137 #define CONTROL_DEFAULT_CATEGORY_BUTTON 10
138 #define CONTROL_DEFAULT_SEPARATOR 11
139 #define CONTROL_DEFAULT_EDIT 12
140 #define CONTROL_START_BUTTONS -100
141 #define CONTROL_START_CONTROL -80
143 CGUIWindowSettingsCategory::CGUIWindowSettingsCategory(void)
144 : CGUIWindow(WINDOW_SETTINGS_MYPICTURES, "SettingsCategory.xml")
146 m_loadType = KEEP_IN_MEMORY;
147 m_pOriginalSpin = NULL;
148 m_pOriginalRadioButton = NULL;
149 m_pOriginalButton = NULL;
150 m_pOriginalCategoryButton = NULL;
151 m_pOriginalImage = NULL;
152 m_pOriginalEdit = NULL;
153 // set the correct ID range...
155 m_idRange.push_back(WINDOW_SETTINGS_MYPICTURES);
156 m_idRange.push_back(WINDOW_SETTINGS_MYPROGRAMS);
157 m_idRange.push_back(WINDOW_SETTINGS_MYWEATHER);
158 m_idRange.push_back(WINDOW_SETTINGS_MYMUSIC);
159 m_idRange.push_back(WINDOW_SETTINGS_SYSTEM);
160 m_idRange.push_back(WINDOW_SETTINGS_MYVIDEOS);
161 m_idRange.push_back(WINDOW_SETTINGS_SERVICE);
162 m_idRange.push_back(WINDOW_SETTINGS_APPEARANCE);
163 m_idRange.push_back(WINDOW_SETTINGS_MYPVR);
166 m_strOldTrackFormat = "";
167 m_strOldTrackFormatRight = "";
168 m_returningFromSkinLoad = false;
169 m_delayedSetting = NULL;
172 CGUIWindowSettingsCategory::~CGUIWindowSettingsCategory(void)
175 delete m_pOriginalEdit;
178 bool CGUIWindowSettingsCategory::OnBack(int actionID)
181 m_lastControlID = 0; // don't save the control as we go to a different window each time
182 return CGUIWindow::OnBack(actionID);
185 bool CGUIWindowSettingsCategory::OnMessage(CGUIMessage &message)
187 switch (message.GetMessage())
189 case GUI_MSG_CLICKED:
191 unsigned int iControl = message.GetSenderId();
192 for (unsigned int i = 0; i < m_vecSettings.size(); i++)
194 if (m_vecSettings[i]->GetID() == (int)iControl)
195 OnClick(m_vecSettings[i]);
199 case GUI_MSG_FOCUSED:
201 CGUIWindow::OnMessage(message);
202 int focusedControl = GetFocusedControlID();
203 if (focusedControl >= CONTROL_START_BUTTONS && focusedControl < (int)(CONTROL_START_BUTTONS + m_vecSections.size()) &&
204 focusedControl - CONTROL_START_BUTTONS != m_iSection && !m_returningFromSkinLoad)
206 // changing section, check for updates and cancel any delayed changes
207 m_delayedSetting = NULL;
210 if (m_vecSections[focusedControl-CONTROL_START_BUTTONS]->m_strCategory == "masterlock")
212 if (!g_passwordManager.IsMasterLockUnlocked(true))
213 { // unable to go to this category - focus the previous one
214 SET_CONTROL_FOCUS(CONTROL_START_BUTTONS + m_iSection, 0);
218 if (m_vecSections[focusedControl-CONTROL_START_BUTTONS]->m_strCategory == "pvrparental")
220 if (!g_PVRManager.CheckParentalPIN(g_localizeStrings.Get(19262).c_str()))
221 { // unable to go to this category - focus the previous one
222 SET_CONTROL_FOCUS(CONTROL_START_BUTTONS + m_iSection, 0);
227 m_iSection = focusedControl - CONTROL_START_BUTTONS;
234 case GUI_MSG_LOAD_SKIN:
237 m_returningFromSkinLoad = true;
240 case GUI_MSG_WINDOW_INIT:
242 m_delayedSetting = NULL;
243 if (message.GetParam1() != WINDOW_INVALID && !m_returningFromSkinLoad)
244 { // coming to this window first time (ie not returning back from some other window)
245 // so we reset our section and control states
247 ResetControlStates();
249 m_iScreen = (int)message.GetParam2() - (int)CGUIWindow::GetID();
250 CGUIWindow::OnMessage(message);
251 m_returningFromSkinLoad = false;
255 case GUI_MSG_UPDATE_ITEM:
256 if (m_delayedSetting)
258 OnSettingChanged(m_delayedSetting);
259 m_delayedSetting = NULL;
264 if (HasID(message.GetSenderId()))
266 int focusedControl = GetFocusedControlID();
268 SET_CONTROL_FOCUS(focusedControl, 0);
271 case GUI_MSG_NOTIFY_ALL:
273 if (message.GetParam1() == GUI_MSG_WINDOW_RESIZE)
275 // Cancel delayed setting - it's only used for res changing anyway
276 m_delayedSetting = NULL;
277 if (IsActive() && g_guiSettings.GetResolution() != g_graphicsContext.GetVideoResolution())
279 g_guiSettings.SetResolution(g_graphicsContext.GetVideoResolution());
285 case GUI_MSG_WINDOW_DEINIT:
287 m_delayedSetting = NULL;
290 CGUIWindow::OnMessage(message);
296 return CGUIWindow::OnMessage(message);
299 void CGUIWindowSettingsCategory::SetupControls()
301 // cleanup first, if necessary
303 m_pOriginalSpin = (CGUISpinControlEx*)GetControl(CONTROL_DEFAULT_SPIN);
304 m_pOriginalRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_DEFAULT_RADIOBUTTON);
305 m_pOriginalCategoryButton = (CGUIButtonControl *)GetControl(CONTROL_DEFAULT_CATEGORY_BUTTON);
306 m_pOriginalButton = (CGUIButtonControl *)GetControl(CONTROL_DEFAULT_BUTTON);
307 m_pOriginalImage = (CGUIImage *)GetControl(CONTROL_DEFAULT_SEPARATOR);
308 if (!m_pOriginalCategoryButton || !m_pOriginalSpin || !m_pOriginalRadioButton || !m_pOriginalButton)
310 m_pOriginalEdit = (CGUIEditControl *)GetControl(CONTROL_DEFAULT_EDIT);
311 if (!m_pOriginalEdit || m_pOriginalEdit->GetControlType() != CGUIControl::GUICONTROL_EDIT)
313 delete m_pOriginalEdit;
314 m_pOriginalEdit = new CGUIEditControl(*m_pOriginalButton);
316 m_pOriginalSpin->SetVisible(false);
317 m_pOriginalRadioButton->SetVisible(false);
318 m_pOriginalButton->SetVisible(false);
319 m_pOriginalCategoryButton->SetVisible(false);
320 m_pOriginalEdit->SetVisible(false);
321 if (m_pOriginalImage) m_pOriginalImage->SetVisible(false);
322 // setup our control groups...
323 CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(CATEGORY_GROUP_ID);
326 // get a list of different sections
327 CSettingsGroup *pSettingsGroup = g_guiSettings.GetGroup(m_iScreen);
328 if (!pSettingsGroup) return ;
329 // update the screen string
330 SET_CONTROL_LABEL(CONTROL_SETTINGS_LABEL, pSettingsGroup->GetLabelID());
331 // get the categories we need
332 pSettingsGroup->GetCategories(m_vecSections);
333 // run through and create our buttons...
335 for (unsigned int i = 0; i < m_vecSections.size(); i++)
337 if (m_vecSections[i]->m_labelID == 12360 && !g_settings.IsMasterUser())
339 CGUIButtonControl *pButton = NULL;
340 if (m_pOriginalCategoryButton->GetControlType() == CGUIControl::GUICONTROL_TOGGLEBUTTON)
341 pButton = new CGUIToggleButtonControl(*(CGUIToggleButtonControl *)m_pOriginalCategoryButton);
343 pButton = new CGUIButtonControl(*m_pOriginalCategoryButton);
344 pButton->SetLabel(g_localizeStrings.Get(m_vecSections[i]->m_labelID));
345 pButton->SetID(CONTROL_START_BUTTONS + j);
346 pButton->SetVisible(true);
347 pButton->AllocResources();
348 group->AddControl(pButton);
351 if (m_iSection < 0 || m_iSection >= (int)m_vecSections.size())
354 // set focus correctly
355 m_defaultControl = CONTROL_START_BUTTONS;
358 CGUIControl* CGUIWindowSettingsCategory::AddIntBasedSpinControl(CSetting *pSetting, float groupWidth, int &iControlID)
360 CSettingInt *pSettingInt = (CSettingInt*)pSetting;
361 CGUISpinControlEx *pControl = (CGUISpinControlEx *)AddSetting(pSetting, groupWidth, iControlID);
362 if (!pSettingInt->m_entries.empty())
364 for (map<int,int>::iterator it=pSettingInt->m_entries.begin(); it != pSettingInt->m_entries.end();++it)
365 pControl->AddLabel(g_localizeStrings.Get(it->first), it->second);
366 pControl->SetValue(pSettingInt->GetData());
371 void CGUIWindowSettingsCategory::CreateSettings()
373 FreeSettingsControls();
375 CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(SETTINGS_GROUP_ID);
378 vecSettings settings;
379 g_guiSettings.GetSettingsGroup(m_vecSections[m_iSection], settings);
380 int iControlID = CONTROL_START_CONTROL;
381 for (unsigned int i = 0; i < settings.size(); i++)
383 CSetting *pSetting = settings[i];
384 CStdString strSetting = pSetting->GetSetting();
385 if (pSetting->GetType() == SETTINGS_TYPE_INT)
387 CGUISpinControlEx *pControl = (CGUISpinControlEx *)AddIntBasedSpinControl(pSetting, group->GetWidth(), iControlID);
388 CSettingInt *pSettingInt = (CSettingInt*)pSetting;
389 if (strSetting.Equals("videoplayer.pauseafterrefreshchange"))
391 pControl->AddLabel(g_localizeStrings.Get(13551), 0);
393 for (int i = 1; i <= MAXREFRESHCHANGEDELAY; i++)
395 CStdString delayText;
396 delayText.Format(g_localizeStrings.Get(13553).c_str(), (double)i / 10.0);
397 pControl->AddLabel(delayText, i);
399 pControl->SetValue(pSettingInt->GetData());
401 else if (strSetting.Equals("subtitles.color"))
403 for (int i = SUBTITLE_COLOR_START; i <= SUBTITLE_COLOR_END; i++)
404 pControl->AddLabel(g_localizeStrings.Get(760 + i), i);
405 pControl->SetValue(pSettingInt->GetData());
407 else if (strSetting.Equals("lookandfeel.startupwindow"))
408 FillInStartupWindow(pSetting);
409 else if (strSetting.Equals("subtitles.height") || strSetting.Equals("karaoke.fontheight") )
410 FillInSubtitleHeights(pSetting, pControl);
411 else if (strSetting.Equals("videoscreen.screen"))
412 FillInScreens(strSetting, g_guiSettings.GetResolution());
413 else if (strSetting.Equals("videoscreen.resolution"))
414 FillInResolutions(strSetting, g_guiSettings.GetInt("videoscreen.screen"), g_guiSettings.GetResolution(), false);
415 else if (strSetting.Equals("epg.defaultguideview"))
416 FillInEpgGuideView(pSetting);
417 else if (strSetting.Equals("pvrplayback.startlast"))
418 FillInPvrStartLastChannel(pSetting);
421 #ifdef HAS_WEB_SERVER
422 else if (strSetting.Equals("services.webserverport"))
424 AddSetting(pSetting, group->GetWidth(), iControlID);
425 CBaseSettingControl *control = GetSetting(pSetting->GetSetting());
426 control->SetDelayed();
430 else if (strSetting.Equals("services.esport"))
432 #ifdef HAS_EVENT_SERVER
433 AddSetting(pSetting, group->GetWidth(), iControlID);
434 CBaseSettingControl *control = GetSetting(pSetting->GetSetting());
435 control->SetDelayed();
439 else if (strSetting.Equals("network.httpproxyport"))
441 AddSetting(pSetting, group->GetWidth(), iControlID);
442 CBaseSettingControl *control = GetSetting(pSetting->GetSetting());
443 control->SetDelayed();
446 else if (strSetting.Equals("subtitles.font") || strSetting.Equals("karaoke.font") )
448 AddSetting(pSetting, group->GetWidth(), iControlID);
449 FillInSubtitleFonts(pSetting);
452 else if (strSetting.Equals("subtitles.charset") || strSetting.Equals("locale.charset") || strSetting.Equals("karaoke.charset"))
454 AddSetting(pSetting, group->GetWidth(), iControlID);
455 FillInCharSets(pSetting);
458 else if (strSetting.Equals("lookandfeel.font"))
460 AddSetting(pSetting, group->GetWidth(), iControlID);
461 FillInSkinFonts(pSetting);
464 else if (strSetting.Equals("lookandfeel.soundskin"))
466 AddSetting(pSetting, group->GetWidth(), iControlID);
467 FillInSoundSkins(pSetting);
470 else if (strSetting.Equals("locale.language"))
472 AddSetting(pSetting, group->GetWidth(), iControlID);
473 GetSetting(pSetting->GetSetting())->SetDelayed();
474 FillInLanguages(pSetting);
477 else if (strSetting.Equals("locale.audiolanguage") || strSetting.Equals("locale.subtitlelanguage"))
479 AddSetting(pSetting, group->GetWidth(), iControlID);
480 vector<CStdString> languages;
481 languages.push_back(g_localizeStrings.Get(308));
482 languages.push_back(g_localizeStrings.Get(309));
483 vector<CStdString> languageKeys;
484 languageKeys.push_back("original");
485 languageKeys.push_back("default");
486 FillInLanguages(pSetting, languages, languageKeys);
490 else if (strSetting.Equals("locale.timezonecountry"))
492 CStdString myTimezoneCountry = g_guiSettings.GetString("locale.timezonecountry");
493 int myTimezeoneCountryIndex = 0;
495 CGUISpinControlEx *pControl = (CGUISpinControlEx *)AddSetting(pSetting, group->GetWidth(), iControlID);
496 vector<CStdString> countries = g_timezone.GetCounties();
497 for (unsigned int i=0; i < countries.size(); i++)
499 if (countries[i] == myTimezoneCountry)
500 myTimezeoneCountryIndex = i;
501 pControl->AddLabel(countries[i], i);
503 pControl->SetValue(myTimezeoneCountryIndex);
506 else if (strSetting.Equals("locale.timezone"))
508 CStdString myTimezoneCountry = g_guiSettings.GetString("locale.timezonecountry");
509 CStdString myTimezone = g_guiSettings.GetString("locale.timezone");
510 int myTimezoneIndex = 0;
512 CGUISpinControlEx *pControl = (CGUISpinControlEx *)AddSetting(pSetting, group->GetWidth(), iControlID);
514 vector<CStdString> timezones = g_timezone.GetTimezonesByCountry(myTimezoneCountry);
515 for (unsigned int i=0; i < timezones.size(); i++)
517 if (timezones[i] == myTimezone)
519 pControl->AddLabel(timezones[i], i);
521 pControl->SetValue(myTimezoneIndex);
525 else if (strSetting.Equals("videoscreen.screenmode"))
527 AddSetting(pSetting, group->GetWidth(), iControlID);
528 FillInRefreshRates(strSetting, g_guiSettings.GetResolution(), false);
531 else if (strSetting.Equals("lookandfeel.skintheme"))
533 AddSetting(pSetting, group->GetWidth(), iControlID);
534 FillInSkinThemes(pSetting);
537 else if (strSetting.Equals("lookandfeel.skincolors"))
539 AddSetting(pSetting, group->GetWidth(), iControlID);
540 FillInSkinColors(pSetting);
544 FIXME: setting is hidden in GUI because not supported properly.
545 else if (strSetting.Equals("videoplayer.displayresolution") || strSetting.Equals("pictures.displayresolution"))
547 FillInResolutions(pSetting);
550 else if (strSetting.Equals("locale.country"))
552 AddSetting(pSetting, group->GetWidth(), iControlID);
553 FillInRegions(pSetting);
556 else if (strSetting.Equals("network.interface"))
558 FillInNetworkInterfaces(pSetting, group->GetWidth(), iControlID);
561 else if (strSetting.Equals("audiooutput.audiodevice"))
563 AddSetting(pSetting, group->GetWidth(), iControlID);
564 FillInAudioDevices(pSetting);
567 else if (strSetting.Equals("audiooutput.passthroughdevice"))
569 AddSetting(pSetting, group->GetWidth(), iControlID);
570 FillInAudioDevices(pSetting,true);
573 AddSetting(pSetting, group->GetWidth(), iControlID);
576 if (m_vecSections[m_iSection]->m_strCategory == "network")
577 NetworkInterfaceChanged();
579 // update our settings (turns controls on/off as appropriate)
583 void CGUIWindowSettingsCategory::UpdateSettings()
585 for (unsigned int i = 0; i < m_vecSettings.size(); i++)
587 CBaseSettingControl *pSettingControl = m_vecSettings[i];
588 pSettingControl->Update();
589 CStdString strSetting = pSettingControl->GetSetting()->GetSetting();
591 if (strSetting.Equals("videoplayer.vdpauUpscalingLevel"))
593 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
596 pControl->SetEnabled(true);
601 if (strSetting.Equals("videoscreen.resolution"))
603 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
605 pControl->SetEnabled(g_guiSettings.GetInt("videoscreen.screen") != DM_WINDOWED);
607 else if (strSetting.Equals("videoscreen.screenmode"))
609 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
611 pControl->SetEnabled(g_guiSettings.GetInt("videoscreen.screen") != DM_WINDOWED);
613 else if (strSetting.Equals("videoscreen.fakefullscreen"))
615 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
617 pControl->SetEnabled(g_guiSettings.GetInt("videoscreen.screen") != DM_WINDOWED);
619 #if defined(TARGET_DARWIN_OSX) || defined(_WIN32)
620 else if (strSetting.Equals("videoscreen.blankdisplays"))
622 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
625 if (g_Windowing.IsFullScreen())
626 pControl->SetEnabled(true);
628 pControl->SetEnabled(false);
632 #if defined(TARGET_DARWIN_OSX)
633 else if (strSetting.Equals("input.appleremotemode"))
635 int remoteMode = g_guiSettings.GetInt("input.appleremotemode");
637 // if it's not disabled, start the event server or else apple remote won't work
638 if ( remoteMode != APPLE_REMOTE_DISABLED )
640 g_guiSettings.SetBool("services.esenabled", true);
641 if (!g_application.StartEventServer())
642 CGUIDialogKaiToast::QueueNotification("DefaultIconWarning.png", g_localizeStrings.Get(33102), g_localizeStrings.Get(33100));
645 // if XBMC helper is running, prompt user before effecting change
646 if ( XBMCHelper::GetInstance().IsRunning() && XBMCHelper::GetInstance().GetMode()!=remoteMode )
649 if (!CGUIDialogYesNo::ShowAndGetInput(13144, 13145, 13146, 13147, -1, -1, cancelled, 10000))
651 // user declined, restore previous spinner state and appleremote mode
652 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
653 g_guiSettings.SetInt("input.appleremotemode", XBMCHelper::GetInstance().GetMode());
654 pControl->SetValue(XBMCHelper::GetInstance().GetMode());
658 // reload configuration
659 XBMCHelper::GetInstance().Configure();
664 // set new configuration.
665 XBMCHelper::GetInstance().Configure();
668 if (XBMCHelper::GetInstance().ErrorStarting() == true)
670 // inform user about error
671 CGUIDialogOK::ShowAndGetInput(13620, 13621, 20022, 20022);
673 // reset spinner to disabled state
674 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
675 pControl->SetValue(APPLE_REMOTE_DISABLED);
678 else if (strSetting.Equals("input.appleremotealwayson"))
680 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
683 int value = g_guiSettings.GetInt("input.appleremotemode");
684 if (value != APPLE_REMOTE_DISABLED)
685 pControl->SetEnabled(true);
687 pControl->SetEnabled(false);
690 else if (strSetting.Equals("input.appleremotesequencetime"))
692 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
695 int value = g_guiSettings.GetInt("input.appleremotemode");
696 if (value == APPLE_REMOTE_UNIVERSAL)
697 pControl->SetEnabled(true);
699 pControl->SetEnabled(false);
703 else if (strSetting.Equals("filelists.allowfiledeletion"))
705 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
706 if (pControl) pControl->SetEnabled(!g_settings.GetCurrentProfile().filesLocked() || g_passwordManager.bMasterUser);
708 else if (strSetting.Equals("filelists.showaddsourcebuttons"))
710 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
711 if (pControl) pControl->SetEnabled(g_settings.GetCurrentProfile().canWriteSources() || g_passwordManager.bMasterUser);
713 else if (strSetting.Equals("masterlock.startuplock"))
715 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
716 if (pControl) pControl->SetEnabled(g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE);
718 else if (strSetting.Equals("pvrmanager.channelscan"))
720 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
721 if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("pvrmanager.enabled") && g_PVRClients && g_PVRClients->GetClientsSupportingChannelScan().size() > 0);
723 else if (strSetting.Equals("pvrmanager.channelmanager") || strSetting.Equals("pvrmenu.searchicons"))
725 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
726 if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("pvrmanager.enabled"));
728 else if (!strSetting.Equals("pvrparental.enabled") &&
729 (strSetting.Equals("pvrparental.pin") || strSetting.Equals("pvrparental.duration")))
731 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
732 if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("pvrparental.enabled"));
734 else if (!strSetting.Equals("services.esenabled")
735 && strSetting.Left(11).Equals("services.es"))
737 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
738 if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("services.esenabled"));
740 else if (strSetting.Equals("services.upnpannounce"))
742 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
743 pControl->SetEnabled(g_guiSettings.GetBool("services.upnpserver"));
745 else if (strSetting.Equals("audiocds.quality"))
746 { // only visible if we are doing non-WAV ripping
747 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
748 if (pControl) pControl->SetEnabled(g_guiSettings.GetInt("audiocds.encoder") != CDDARIP_ENCODER_WAV &&
749 g_guiSettings.GetInt("audiocds.encoder") != CDDARIP_ENCODER_FLAC);
751 else if (strSetting.Equals("audiocds.bitrate"))
752 { // only visible if we are ripping to CBR
753 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
754 if (pControl) pControl->SetEnabled(g_guiSettings.GetInt("audiocds.encoder") != CDDARIP_ENCODER_WAV &&
755 g_guiSettings.GetInt("audiocds.encoder") != CDDARIP_ENCODER_FLAC &&
756 g_guiSettings.GetInt("audiocds.quality") == CDDARIP_QUALITY_CBR);
758 else if (strSetting.Equals("audiocds.compressionlevel"))
759 { // only visible if we are doing FLAC ripping
760 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
761 if (pControl) pControl->SetEnabled(g_guiSettings.GetInt("audiocds.encoder") == CDDARIP_ENCODER_FLAC);
764 strSetting.Equals("audiooutput.passthroughdevice") ||
765 strSetting.Equals("audiooutput.ac3passthrough") ||
766 strSetting.Equals("audiooutput.dtspassthrough") ||
767 strSetting.Equals("audiooutput.passthroughaac"))
768 { // only visible if we are in digital mode
769 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
770 if (pControl) pControl->SetEnabled(AUDIO_IS_BITSTREAM(g_guiSettings.GetInt("audiooutput.mode")));
773 strSetting.Equals("audiooutput.multichannellpcm" ) ||
774 strSetting.Equals("audiooutput.truehdpassthrough") ||
775 strSetting.Equals("audiooutput.dtshdpassthrough" ))
777 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
780 if (strSetting.Equals("audiooutput.dtshdpassthrough") && !g_guiSettings.GetBool("audiooutput.dtspassthrough"))
781 pControl->SetEnabled(false);
783 pControl->SetEnabled(g_guiSettings.GetInt("audiooutput.mode") == AUDIO_HDMI);
786 else if (strSetting.Equals("musicplayer.crossfade"))
788 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
789 if (pControl) pControl->SetEnabled(g_guiSettings.GetString("audiooutput.audiodevice").find("wasapi:") == CStdString::npos);
791 else if (strSetting.Equals("musicplayer.crossfadealbumtracks"))
793 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
794 if (pControl) pControl->SetEnabled(g_guiSettings.GetInt("musicplayer.crossfade") > 0 &&
795 g_guiSettings.GetString("audiooutput.audiodevice").find("wasapi:") == CStdString::npos);
797 #ifdef HAS_WEB_SERVER
798 else if (strSetting.Equals("services.webserverusername") ||
799 strSetting.Equals("services.webserverpassword"))
801 CGUIEditControl *pControl = (CGUIEditControl *)GetControl(pSettingControl->GetID());
803 pControl->SetEnabled(g_guiSettings.GetBool("services.webserver"));
807 else if ( strSetting.Equals("services.airplaypassword") ||
808 strSetting.Equals("services.useairplaypassword"))
810 if (strSetting.Equals("services.airplaypassword"))
812 CGUIEditControl *pControl = (CGUIEditControl *)GetControl(pSettingControl->GetID());
814 pControl->SetEnabled(g_guiSettings.GetBool("services.useairplaypassword"));
816 else//useairplaypassword
818 CGUIRadioButtonControl *pControl = (CGUIRadioButtonControl *)GetControl(pSettingControl->GetID());
820 pControl->SetEnabled(g_guiSettings.GetBool("services.airplay"));
823 //set credentials to airplay server
824 if (g_guiSettings.GetBool("services.airplay"))
826 CStdString password = g_guiSettings.GetString("services.airplaypassword");
827 CAirPlayServer::SetCredentials(g_guiSettings.GetBool("services.useairplaypassword"),
832 else if (strSetting.Equals("network.ipaddress") || strSetting.Equals("network.subnet") || strSetting.Equals("network.gateway") || strSetting.Equals("network.dns"))
835 bool enabled = (geteuid() == 0);
837 bool enabled = false;
839 CGUISpinControlEx* pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.assignment")->GetID());
841 enabled = (pControl1->GetValue() == NETWORK_STATIC);
843 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
844 if (pControl) pControl->SetEnabled(enabled);
846 else if (strSetting.Equals("network.assignment"))
848 CGUISpinControlEx* pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.assignment")->GetID());
849 #ifdef HAS_LINUX_NETWORK
851 pControl1->SetEnabled(geteuid() == 0);
854 else if (strSetting.Equals("network.essid") || strSetting.Equals("network.enc") || strSetting.Equals("network.key"))
856 // Get network information
857 CGUISpinControlEx *ifaceControl = (CGUISpinControlEx *)GetControl(GetSetting("network.interface")->GetID());
858 CStdString ifaceName = ifaceControl->GetLabel();
859 CNetworkInterface* iface = g_application.getNetwork().GetInterfaceByName(ifaceName);
860 bool bIsWireless = iface->IsWireless();
862 #ifdef HAS_LINUX_NETWORK
863 bool enabled = bIsWireless && (geteuid() == 0);
865 bool enabled = bIsWireless;
867 CGUISpinControlEx* pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.assignment")->GetID());
869 enabled &= (pControl1->GetValue() != NETWORK_DISABLED);
871 if (strSetting.Equals("network.key"))
873 pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.enc")->GetID());
874 if (pControl1) enabled &= (pControl1->GetValue() != ENC_NONE);
877 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
878 if (pControl) pControl->SetEnabled(enabled);
880 else if (strSetting.Equals("network.httpproxyserver") || strSetting.Equals("network.httpproxyport") ||
881 strSetting.Equals("network.httpproxyusername") || strSetting.Equals("network.httpproxypassword"))
883 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
884 if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("network.usehttpproxy"));
886 #ifdef HAS_LINUX_NETWORK
887 else if (strSetting.Equals("network.key"))
889 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
890 CGUISpinControlEx* pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.enc")->GetID());
891 if (pControl && pControl1)
892 pControl->SetEnabled(!pControl1->IsDisabled() && pControl1->GetValue() > 0);
894 else if (strSetting.Equals("network.save"))
896 CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(pSettingControl->GetID());
897 pControl->SetEnabled(geteuid() == 0);
900 else if (strSetting.Equals("scrobbler.lastfmusername") || strSetting.Equals("scrobbler.lastfmpass"))
902 CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(pSettingControl->GetID());
904 pControl->SetEnabled(g_guiSettings.GetBool("scrobbler.lastfmsubmit") | g_guiSettings.GetBool("scrobbler.lastfmsubmitradio"));
906 else if (strSetting.Equals("scrobbler.librefmusername") || strSetting.Equals("scrobbler.librefmpass"))
908 CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(pSettingControl->GetID());
909 if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("scrobbler.librefmsubmit"));
911 else if (strSetting.Equals("subtitles.color") || strSetting.Equals("subtitles.style") || strSetting.Equals("subtitles.charset"))
913 CGUIControl *pControl = (CGUIControl *)GetControl(GetSetting(strSetting)->GetID());
914 pControl->SetEnabled(CUtil::IsUsingTTFSubtitles());
916 else if (strSetting.Equals("locale.charset"))
917 { // TODO: Determine whether we are using a TTF font or not.
918 // CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
919 // if (pControl) pControl->SetEnabled(g_guiSettings.GetString("lookandfeel.font").Right(4) == ".ttf");
921 else if (strSetting.Equals("screensaver.settings"))
923 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
925 if (CAddonMgr::Get().GetAddon(g_guiSettings.GetString("screensaver.mode"), addon, ADDON_SCREENSAVER))
926 pControl->SetEnabled(addon->HasSettings());
928 pControl->SetEnabled(false);
930 else if (strSetting.Equals("screensaver.preview") ||
931 strSetting.Equals("screensaver.usedimonpause") ||
932 strSetting.Equals("screensaver.usemusicvisinstead"))
934 CGUIControl *pControl = (CGUIControl *)GetControl(GetSetting(strSetting)->GetID());
935 pControl->SetEnabled(!g_guiSettings.GetString("screensaver.mode").IsEmpty());
936 if (strSetting.Equals("screensaver.usedimonpause") && g_guiSettings.GetString("screensaver.mode").Equals("screensaver.xbmc.builtin.dim"))
937 pControl->SetEnabled(false);
939 else if (strSetting.Equals("musicfiles.trackformat"))
941 if (m_strOldTrackFormat != g_guiSettings.GetString("musicfiles.trackformat"))
943 CUtil::DeleteMusicDatabaseDirectoryCache();
944 m_strOldTrackFormat = g_guiSettings.GetString("musicfiles.trackformat");
947 else if (strSetting.Equals("musicfiles.trackformatright"))
949 if (m_strOldTrackFormatRight != g_guiSettings.GetString("musicfiles.trackformatright"))
951 CUtil::DeleteMusicDatabaseDirectoryCache();
952 m_strOldTrackFormatRight = g_guiSettings.GetString("musicfiles.trackformatright");
955 #ifdef HAS_TIME_SERVER
956 else if (strSetting.Equals("locale.timeserveraddress"))
958 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
959 if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("locale.timeserver"));
962 else if (strSetting.Equals("audiocds.recordingpath") || strSetting.Equals("debug.screenshotpath"))
964 CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(pSettingControl->GetID());
965 if (pControl && g_guiSettings.GetString(strSetting, false).IsEmpty())
966 pControl->SetLabel2("");
968 else if (strSetting.Equals("lookandfeel.rssedit"))
970 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
971 pControl->SetEnabled(g_guiSettings.GetBool("lookandfeel.enablerssfeeds"));
973 else if (strSetting.Equals("lookandfeel.skinsettings"))
975 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
976 pControl->SetEnabled(g_SkinInfo->HasSkinFile("SkinSettings.xml"));
978 else if (strSetting.Equals("videoplayer.pauseafterrefreshchange"))
980 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
981 if (pControl) pControl->SetEnabled(g_guiSettings.GetInt("videoplayer.adjustrefreshrate") != ADJUST_REFRESHRATE_OFF);
983 else if (strSetting.Equals("videoplayer.synctype"))
985 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
986 if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("videoplayer.usedisplayasclock"));
988 else if (strSetting.Equals("videoplayer.maxspeedadjust"))
990 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
993 bool enabled = (g_guiSettings.GetBool("videoplayer.usedisplayasclock")) &&
994 (g_guiSettings.GetInt("videoplayer.synctype") == SYNC_RESAMPLE);
995 pControl->SetEnabled(enabled);
998 else if (strSetting.Equals("videoplayer.resamplequality"))
1000 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
1003 bool enabled = (g_guiSettings.GetBool("videoplayer.usedisplayasclock")) &&
1004 (g_guiSettings.GetInt("videoplayer.synctype") == SYNC_RESAMPLE);
1005 pControl->SetEnabled(enabled);
1008 else if (strSetting.Equals("weather.addonsettings"))
1011 if (CAddonMgr::Get().GetAddon(g_guiSettings.GetString("weather.addon"), addon, ADDON_SCRIPT_WEATHER))
1013 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
1015 pControl->SetEnabled(addon->HasSettings());
1018 else if (strSetting.Equals("input.peripherals"))
1020 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
1022 pControl->SetEnabled(g_peripherals.GetNumberOfPeripherals() > 0);
1026 g_guiSettings.SetChanged();
1027 g_guiSettings.NotifyObservers(ObservableMessageGuiSettings);
1030 void CGUIWindowSettingsCategory::OnClick(CBaseSettingControl *pSettingControl)
1032 CStdString strSetting = pSettingControl->GetSetting()->GetSetting();
1033 if (strSetting.Equals("weather.addonsettings"))
1035 CStdString name = g_guiSettings.GetString("weather.addon");
1037 if (CAddonMgr::Get().GetAddon(name, addon, ADDON_SCRIPT_WEATHER))
1038 { // TODO: maybe have ShowAndGetInput return a bool if settings changed, then only reset weather if true.
1039 CGUIDialogAddonSettings::ShowAndGetInput(addon);
1040 g_weatherManager.Refresh();
1043 else if (strSetting.Equals("lookandfeel.rssedit"))
1046 CAddonMgr::Get().GetAddon("script.rss.editor",addon);
1049 if (!CGUIDialogYesNo::ShowAndGetInput(g_localizeStrings.Get(24076), g_localizeStrings.Get(24100),"RSS Editor",g_localizeStrings.Get(24101)))
1051 CAddonInstaller::Get().Install("script.rss.editor", true, "", false);
1053 CBuiltins::Execute("RunScript(script.rss.editor)");
1055 else if (pSettingControl->GetSetting()->GetType() == SETTINGS_TYPE_ADDON)
1056 { // prompt for the addon
1057 CSettingAddon *setting = (CSettingAddon *)pSettingControl->GetSetting();
1058 CStdString addonID = setting->GetData();
1059 if (CGUIWindowAddonBrowser::SelectAddonID(setting->m_type, addonID, setting->m_type == ADDON_SCREENSAVER || setting->m_type == ADDON_VIZ || setting->m_type == ADDON_SCRIPT_WEATHER) == 1)
1060 setting->SetData(addonID);
1064 else if (strSetting.Equals("input.peripherals"))
1066 CGUIDialogPeripheralManager *dialog = (CGUIDialogPeripheralManager *)g_windowManager.GetWindow(WINDOW_DIALOG_PERIPHERAL_MANAGER);
1072 // if OnClick() returns false, the setting hasn't changed or doesn't
1073 // require immediate update
1074 if (!pSettingControl->OnClick())
1077 if (!pSettingControl->IsDelayed())
1081 if (pSettingControl->IsDelayed())
1082 { // delayed setting
1083 m_delayedSetting = pSettingControl;
1084 m_delayedTimer.StartZero();
1087 OnSettingChanged(pSettingControl);
1090 void CGUIWindowSettingsCategory::CheckForUpdates()
1092 for (unsigned int i = 0; i < m_vecSettings.size(); i++)
1094 CBaseSettingControl *pSettingControl = m_vecSettings[i];
1095 if (pSettingControl->NeedsUpdate())
1097 OnSettingChanged(pSettingControl);
1098 pSettingControl->Reset();
1103 void CGUIWindowSettingsCategory::OnSettingChanged(CBaseSettingControl *pSettingControl)
1105 CStdString strSetting = pSettingControl->GetSetting()->GetSetting();
1107 // ok, now check the various special things we need to do
1108 if (pSettingControl->GetSetting()->GetType() == SETTINGS_TYPE_ADDON)
1110 CSettingAddon *pSettingAddon = (CSettingAddon*)pSettingControl->GetSetting();
1111 if (pSettingAddon->m_type == ADDON_SKIN)
1113 g_application.ReloadSkin();
1115 else if (pSettingAddon->m_type == ADDON_SCRIPT_WEATHER)
1117 g_weatherManager.Refresh();
1120 else if (strSetting.Equals("musicplayer.visualisation"))
1121 { // new visualisation choosen...
1122 CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
1123 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1124 if (pControl->GetValue() == 0)
1125 pSettingString->SetData("None");
1127 pSettingString->SetData(pControl->GetCurrentLabel());
1129 else if (strSetting.Equals("debug.showloginfo"))
1131 g_advancedSettings.SetDebugMode(g_guiSettings.GetBool("debug.showloginfo"));
1133 /*else if (strSetting.Equals("musicfiles.repeat"))
1135 g_playlistPlayer.SetRepeat(PLAYLIST_MUSIC_TEMP, g_guiSettings.GetBool("musicfiles.repeat") ? PLAYLIST::REPEAT_ALL : PLAYLIST::REPEAT_NONE);
1137 else if (strSetting.Equals("musiclibrary.cleanup"))
1139 CMusicDatabase musicdatabase;
1140 musicdatabase.Clean();
1141 CUtil::DeleteMusicDatabaseDirectoryCache();
1143 else if (strSetting.Equals("videolibrary.cleanup"))
1145 if (CGUIDialogYesNo::ShowAndGetInput(313, 333, 0, 0))
1146 g_application.StartVideoCleanup();
1148 else if (strSetting.Equals("videolibrary.export"))
1149 CBuiltins::Execute("exportlibrary(video)");
1150 else if (strSetting.Equals("musiclibrary.export"))
1151 CBuiltins::Execute("exportlibrary(music)");
1152 else if (strSetting.Equals("karaoke.export") )
1154 CContextButtons choices;
1155 choices.Add(1, g_localizeStrings.Get(22034));
1156 choices.Add(2, g_localizeStrings.Get(22035));
1158 int retVal = CGUIDialogContextMenu::ShowAndGetChoice(choices);
1161 CStdString path(g_settings.GetDatabaseFolder());
1163 g_mediaManager.GetLocalDrives(shares);
1164 if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares, g_localizeStrings.Get(661), path, true))
1166 CMusicDatabase musicdatabase;
1167 musicdatabase.Open();
1171 URIUtils::AddFileToFolder(path, "karaoke.html", path);
1172 musicdatabase.ExportKaraokeInfo( path, true );
1176 URIUtils::AddFileToFolder(path, "karaoke.csv", path);
1177 musicdatabase.ExportKaraokeInfo( path, false );
1179 musicdatabase.Close();
1183 else if (strSetting.Equals("videolibrary.import"))
1187 g_mediaManager.GetLocalDrives(shares);
1188 if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares, g_localizeStrings.Get(651) , path))
1190 CVideoDatabase videodatabase;
1191 videodatabase.Open();
1192 videodatabase.ImportFromXML(path);
1193 videodatabase.Close();
1196 else if (strSetting.Equals("musiclibrary.import"))
1200 g_mediaManager.GetLocalDrives(shares);
1201 if (CGUIDialogFileBrowser::ShowAndGetFile(shares, "musicdb.xml", g_localizeStrings.Get(651) , path))
1203 CMusicDatabase musicdatabase;
1204 musicdatabase.Open();
1205 musicdatabase.ImportFromXML(path);
1206 musicdatabase.Close();
1209 else if (strSetting.Equals("karaoke.importcsv"))
1211 CStdString path(g_settings.GetDatabaseFolder());
1213 g_mediaManager.GetLocalDrives(shares);
1214 if (CGUIDialogFileBrowser::ShowAndGetFile(shares, "karaoke.csv", g_localizeStrings.Get(651) , path))
1216 CMusicDatabase musicdatabase;
1217 musicdatabase.Open();
1218 musicdatabase.ImportKaraokeInfo(path);
1219 musicdatabase.Close();
1222 else if (strSetting.Equals("scrobbler.lastfmsubmit") || strSetting.Equals("scrobbler.lastfmsubmitradio") || strSetting.Equals("scrobbler.lastfmusername") || strSetting.Equals("scrobbler.lastfmpass"))
1224 CStdString strPassword=g_guiSettings.GetString("scrobbler.lastfmpass");
1225 CStdString strUserName=g_guiSettings.GetString("scrobbler.lastfmusername");
1226 if ((g_guiSettings.GetBool("scrobbler.lastfmsubmit") ||
1227 g_guiSettings.GetBool("scrobbler.lastfmsubmitradio")) &&
1228 !strUserName.IsEmpty() && !strPassword.IsEmpty())
1230 CLastfmScrobbler::GetInstance()->Init();
1234 CLastfmScrobbler::GetInstance()->Term();
1237 else if (strSetting.Equals("scrobbler.librefmsubmit") || strSetting.Equals("scrobbler.librefmsubmitradio") || strSetting.Equals("scrobbler.librefmusername") || strSetting.Equals("scrobbler.librefmpass"))
1239 CStdString strPassword=g_guiSettings.GetString("scrobbler.librefmpass");
1240 CStdString strUserName=g_guiSettings.GetString("scrobbler.librefmusername");
1241 if ((g_guiSettings.GetBool("scrobbler.librefmsubmit") ||
1242 g_guiSettings.GetBool("scrobbler.librefmsubmitradio")) &&
1243 !strUserName.IsEmpty() && !strPassword.IsEmpty())
1245 CLibrefmScrobbler::GetInstance()->Init();
1249 CLibrefmScrobbler::GetInstance()->Term();
1252 else if (strSetting.Left(22).Equals("MusicPlayer.ReplayGain"))
1253 { // Update our replaygain settings
1254 g_guiSettings.m_replayGain.iType = g_guiSettings.GetInt("musicplayer.replaygaintype");
1255 g_guiSettings.m_replayGain.iPreAmp = g_guiSettings.GetInt("musicplayer.replaygainpreamp");
1256 g_guiSettings.m_replayGain.iNoGainPreAmp = g_guiSettings.GetInt("musicplayer.replaygainnogainpreamp");
1257 g_guiSettings.m_replayGain.bAvoidClipping = g_guiSettings.GetBool("musicplayer.replaygainavoidclipping");
1260 else if (strSetting.Equals("videoscreen.haslcd"))
1263 CLCDFactory factory;
1265 g_lcd = factory.Create();
1266 g_lcd->Initialize();
1269 #ifdef HAS_WEB_SERVER
1270 else if ( strSetting.Equals("services.webserver") || strSetting.Equals("services.webserverport"))
1272 if (strSetting.Equals("services.webserverport"))
1273 ValidatePortNumber(pSettingControl, "8080", "80");
1274 g_application.StopWebServer();
1275 if (g_guiSettings.GetBool("services.webserver"))
1276 if (!g_application.StartWebServer())
1278 CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33101), "", g_localizeStrings.Get(33100), "");
1279 g_guiSettings.SetBool("services.webserver", false);
1282 else if (strSetting.Equals("services.webserverusername") || strSetting.Equals("services.webserverpassword"))
1284 g_application.m_WebServer.SetCredentials(g_guiSettings.GetString("services.webserverusername"), g_guiSettings.GetString("services.webserverpassword"));
1287 else if (strSetting.Equals("services.zeroconf"))
1290 //ifdef zeroconf here because it's only found in guisettings if defined
1291 if(g_guiSettings.GetBool("services.zeroconf"))
1293 CZeroconf::GetInstance()->Stop();
1294 CZeroconf::GetInstance()->Start();
1299 g_application.StopAirplayServer(true);
1300 g_guiSettings.SetBool("services.airplay", false);
1301 CZeroconf::GetInstance()->Stop();
1306 else if (strSetting.Equals("services.airplay"))
1309 if (g_guiSettings.GetBool("services.airplay"))
1312 // AirPlay needs zeroconf
1313 if(!g_guiSettings.GetBool("services.zeroconf"))
1315 g_guiSettings.SetBool("services.zeroconf", true);
1316 CZeroconf::GetInstance()->Stop();
1317 CZeroconf::GetInstance()->Start();
1319 #endif //HAS_ZEROCONF
1320 g_application.StartAirplayServer();//will stop the server before internal
1323 g_application.StopAirplayServer(true);//will stop the server before internal
1326 else if (strSetting.Equals("network.ipaddress"))
1328 if (g_guiSettings.GetInt("network.assignment") == NETWORK_STATIC)
1330 CStdString strDefault = g_guiSettings.GetString("network.ipaddress").Left(g_guiSettings.GetString("network.ipaddress").ReverseFind('.'))+".1";
1331 if (g_guiSettings.GetString("network.gateway").Equals("0.0.0.0"))
1332 g_guiSettings.SetString("network.gateway",strDefault);
1333 if (g_guiSettings.GetString("network.dns").Equals("0.0.0.0"))
1334 g_guiSettings.SetString("network.dns",strDefault);
1339 else if (strSetting.Equals("network.httpproxyport"))
1341 ValidatePortNumber(pSettingControl, "8080", "8080", false);
1343 else if (strSetting.Equals("videoplayer.calibrate") || strSetting.Equals("videoscreen.guicalibration"))
1344 { // activate the video calibration screen
1345 g_windowManager.ActivateWindow(WINDOW_SCREEN_CALIBRATION);
1347 else if (strSetting.Equals("videoscreen.testpattern"))
1348 { // activate the test pattern
1349 g_windowManager.ActivateWindow(WINDOW_TEST_PATTERN);
1351 else if (strSetting.Equals("subtitles.height"))
1353 if (!CUtil::IsUsingTTFSubtitles())
1355 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1356 ((CSettingInt *)pSettingControl->GetSetting())->FromString(pControl->GetCurrentLabel());
1359 else if (strSetting.Equals("subtitles.font"))
1361 CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
1362 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1363 pSettingString->SetData(pControl->GetCurrentLabel());
1364 CSetting *pSetting = (CSetting *)g_guiSettings.GetSetting("subtitles.height");
1365 FillInSubtitleHeights(pSetting, (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID()));
1367 else if (strSetting.Equals("subtitles.charset"))
1369 CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
1370 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1371 CStdString newCharset="DEFAULT";
1372 if (pControl->GetValue()!=0)
1373 newCharset = g_charsetConverter.getCharsetNameByLabel(pControl->GetCurrentLabel());
1374 if (newCharset != "" && (newCharset != pSettingString->GetData() || newCharset=="DEFAULT"))
1376 pSettingString->SetData(newCharset);
1377 g_charsetConverter.reset();
1380 else if (strSetting.Equals("karaoke.fontheight"))
1382 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1383 ((CSettingInt *)pSettingControl->GetSetting())->FromString(pControl->GetCurrentLabel());
1385 else if (strSetting.Equals("karaoke.font"))
1387 CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
1388 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1389 pSettingString->SetData(pControl->GetCurrentLabel());
1390 CSetting *pSetting = (CSetting *)g_guiSettings.GetSetting("karaoke.fontheight");
1391 FillInSubtitleHeights(pSetting, (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID()));
1393 else if (strSetting.Equals("karaoke.charset"))
1395 CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
1396 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1397 CStdString newCharset="DEFAULT";
1398 if (pControl->GetValue()!=0)
1399 newCharset = g_charsetConverter.getCharsetNameByLabel(pControl->GetCurrentLabel());
1400 if (newCharset != "" && (newCharset != pSettingString->GetData() || newCharset=="DEFAULT"))
1402 pSettingString->SetData(newCharset);
1403 g_charsetConverter.reset();
1406 else if (strSetting.Equals("locale.charset"))
1408 CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
1409 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1410 CStdString newCharset="DEFAULT";
1411 if (pControl->GetValue()!=0)
1412 newCharset = g_charsetConverter.getCharsetNameByLabel(pControl->GetCurrentLabel());
1413 if (newCharset != "" && (newCharset != pSettingString->GetData() || newCharset=="DEFAULT"))
1415 pSettingString->SetData(newCharset);
1416 g_charsetConverter.reset();
1419 else if (strSetting.Equals("lookandfeel.font"))
1420 { // new font choosen...
1421 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1422 CStdString strSkinFontSet = m_SkinFontSetIDs[pControl->GetCurrentLabel()];
1423 if (strSkinFontSet != ".svn" && strSkinFontSet != g_guiSettings.GetString("lookandfeel.font"))
1425 g_guiSettings.SetString("lookandfeel.font", strSkinFontSet);
1426 g_application.ReloadSkin();
1429 else if (strSetting.Equals("lookandfeel.soundskin"))
1430 { // new sound skin choosen...
1431 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1432 if (pControl->GetValue()==0)
1433 g_guiSettings.SetString("lookandfeel.soundskin", "OFF");
1434 else if (pControl->GetValue()==1)
1435 g_guiSettings.SetString("lookandfeel.soundskin", "SKINDEFAULT");
1437 g_guiSettings.SetString("lookandfeel.soundskin", pControl->GetCurrentLabel());
1439 g_audioManager.Enable(true);
1440 g_audioManager.Load();
1442 else if (strSetting.Equals("lookandfeel.skinsettings"))
1444 g_windowManager.ActivateWindow(WINDOW_SKIN_SETTINGS);
1446 else if (strSetting.Equals("input.enablemouse"))
1448 g_Mouse.SetEnabled(g_guiSettings.GetBool("input.enablemouse"));
1450 else if (strSetting.Equals("input.enablejoystick") || strSetting.Equals("input.disablejoystickwithimon"))
1452 #if defined(HAS_SDL_JOYSTICK)
1453 g_Joystick.SetEnabled(g_guiSettings.GetBool("input.enablejoystick")
1454 && (CPeripheralImon::GetCountOfImonsConflictWithDInput() == 0 || !g_guiSettings.GetBool("input.disablejoystickwithimon")) );
1457 else if (strSetting.Equals("videoscreen.screen"))
1459 DisplayMode mode = g_guiSettings.GetInt("videoscreen.screen");
1461 FillInResolutions("videoscreen.resolution", mode, RES_DESKTOP, true);
1463 else if (strSetting.Equals("videoscreen.resolution"))
1465 RESOLUTION nextRes = (RESOLUTION) g_guiSettings.GetInt("videoscreen.resolution");
1467 FillInRefreshRates("videoscreen.screenmode", nextRes, true);
1469 else if (strSetting.Equals("videoscreen.screenmode"))
1471 int iControlID = pSettingControl->GetID();
1472 CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), iControlID);
1473 g_windowManager.SendMessage(msg);
1474 RESOLUTION nextRes = (RESOLUTION)msg.GetParam1();
1476 OnRefreshRateChanged(nextRes);
1478 else if (strSetting.Equals("videoscreen.vsync"))
1480 int iControlID = pSettingControl->GetID();
1481 CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), iControlID);
1482 g_windowManager.SendMessage(msg);
1483 // DXMERGE: This may be useful
1484 // g_videoConfig.SetVSyncMode((VSYNC)msg.GetParam1());
1486 else if (strSetting.Equals("videoscreen.fakefullscreen"))
1488 if (g_graphicsContext.IsFullScreenRoot())
1489 g_graphicsContext.SetVideoResolution(g_graphicsContext.GetVideoResolution(), true);
1491 else if (strSetting.Equals("locale.audiolanguage"))
1492 { // new audio language chosen...
1493 CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
1494 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1495 int iLanguage = pControl->GetValue();
1499 g_guiSettings.SetString(strSetting, "original");
1501 g_guiSettings.SetString(strSetting, "default");
1502 g_langInfo.SetAudioLanguage("");
1506 CStdString strLanguage = pControl->GetCurrentLabel();
1507 if (strLanguage != pSettingString->GetData())
1509 g_guiSettings.SetString(strSetting, strLanguage);
1510 g_langInfo.SetAudioLanguage(strLanguage);
1514 else if (strSetting.Equals("locale.subtitlelanguage"))
1515 { // new subtitle language chosen...
1516 CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
1517 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1518 int iLanguage = pControl->GetValue();
1522 g_guiSettings.SetString(strSetting, "original");
1524 g_guiSettings.SetString(strSetting, "default");
1525 g_langInfo.SetSubtitleLanguage("");
1529 CStdString strLanguage = pControl->GetCurrentLabel();
1530 if (strLanguage != pSettingString->GetData())
1532 g_guiSettings.SetString(strSetting, strLanguage);
1533 g_langInfo.SetSubtitleLanguage(strLanguage);
1537 else if (strSetting.Equals("locale.language"))
1538 { // new language chosen...
1539 CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
1540 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1541 CStdString strLanguage = pControl->GetCurrentLabel();
1542 if (strLanguage != ".svn" && strLanguage != pSettingString->GetData())
1543 g_guiSettings.SetLanguage(strLanguage);
1545 else if (strSetting.Equals("lookandfeel.skintheme"))
1546 { //a new Theme was chosen
1547 CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
1548 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1550 CStdString strSkinTheme;
1552 if (pControl->GetValue() == 0) // Use default theme
1553 strSkinTheme = "SKINDEFAULT";
1555 strSkinTheme = pControl->GetCurrentLabel();
1557 if (strSkinTheme != pSettingString->GetData())
1559 g_guiSettings.SetString("lookandfeel.skintheme", strSkinTheme);
1560 // also set the default color theme
1561 CStdString colorTheme(URIUtils::ReplaceExtension(strSkinTheme, ".xml"));
1562 if (colorTheme.Equals("Textures.xml"))
1563 colorTheme = "defaults.xml";
1564 g_guiSettings.SetString("lookandfeel.skincolors", colorTheme);
1565 g_application.ReloadSkin();
1568 else if (strSetting.Equals("lookandfeel.skincolors"))
1569 { //a new color was chosen
1570 CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
1571 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1573 CStdString strSkinColor;
1575 if (pControl->GetValue() == 0) // Use default colors
1576 strSkinColor = "SKINDEFAULT";
1578 strSkinColor = pControl->GetCurrentLabel() + ".xml";
1580 if (strSkinColor != pSettingString->GetData())
1582 g_guiSettings.SetString("lookandfeel.skincolors", strSkinColor);
1583 g_application.ReloadSkin();
1586 else if (strSetting.Equals("videoplayer.displayresolution"))
1588 CSettingInt *pSettingInt = (CSettingInt *)pSettingControl->GetSetting();
1589 int iControlID = pSettingControl->GetID();
1590 CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), iControlID);
1591 g_windowManager.SendMessage(msg);
1592 pSettingInt->SetData(msg.GetParam1());
1594 else if (strSetting.Equals("videoscreen.flickerfilter") || strSetting.Equals("videoscreen.soften"))
1596 g_graphicsContext.SetVideoResolution(g_guiSettings.m_LookAndFeelResolution);
1598 else if (strSetting.Equals("screensaver.preview"))
1600 g_application.ActivateScreenSaver(true);
1602 else if (strSetting.Equals("screensaver.settings"))
1605 if (CAddonMgr::Get().GetAddon(g_guiSettings.GetString("screensaver.mode"), addon, ADDON_SCREENSAVER))
1606 CGUIDialogAddonSettings::ShowAndGetInput(addon);
1608 else if (strSetting.Equals("debug.screenshotpath") || strSetting.Equals("audiocds.recordingpath") || strSetting.Equals("subtitles.custompath") || strSetting.Equals("pvrmenu.iconpath"))
1610 CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
1611 CStdString path = g_guiSettings.GetString(strSetting,false);
1614 bool bWriteOnly = true;
1616 if (strSetting.Equals("pvrmenu.iconpath"))
1620 else if (strSetting.Equals("subtitles.custompath"))
1623 shares = g_settings.m_videoSources;
1626 g_mediaManager.GetNetworkLocations(shares);
1627 g_mediaManager.GetLocalDrives(shares);
1631 if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares, g_localizeStrings.Get(pSettingString->m_iHeadingString), path, bWriteOnly))
1633 pSettingString->SetData(path);
1636 else if (strSetting.Left(22).Equals("MusicPlayer.ReplayGain"))
1637 { // Update our replaygain settings
1638 g_guiSettings.m_replayGain.iType = g_guiSettings.GetInt("musicplayer.replaygaintype");
1639 g_guiSettings.m_replayGain.iPreAmp = g_guiSettings.GetInt("musicplayer.replaygainpreamp");
1640 g_guiSettings.m_replayGain.iNoGainPreAmp = g_guiSettings.GetInt("musicplayer.replaygainnogainpreamp");
1641 g_guiSettings.m_replayGain.bAvoidClipping = g_guiSettings.GetBool("musicplayer.replaygainavoidclipping");
1643 else if (strSetting.Equals("locale.country"))
1645 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1647 const CStdString& strRegion=pControl->GetCurrentLabel();
1648 g_langInfo.SetCurrentRegion(strRegion);
1649 g_guiSettings.SetString("locale.country", strRegion);
1650 g_weatherManager.Refresh(); // need to reset our weather, as temperatures need re-translating.
1652 #ifdef HAS_TIME_SERVER
1653 else if (strSetting.Equals("locale.timeserver") || strSetting.Equals("locale.timeserveraddress"))
1655 g_application.StopTimeServer();
1656 if (g_guiSettings.GetBool("locale.timeserver"))
1657 g_application.StartTimeServer();
1660 else if (strSetting.Equals("smb.winsserver") || strSetting.Equals("smb.workgroup") )
1662 if (g_guiSettings.GetString("smb.winsserver") == "0.0.0.0")
1663 g_guiSettings.SetString("smb.winsserver", "");
1665 /* okey we really don't need to restarat, only deinit samba, but that could be damn hard if something is playing*/
1666 //TODO - General way of handling setting changes that require restart
1668 if (CGUIDialogYesNo::ShowAndGetInput(14038, 14039, 14040, -1, -1))
1671 CApplicationMessenger::Get().RestartApp();
1674 else if (strSetting.Equals("services.upnpserver"))
1677 if (g_guiSettings.GetBool("services.upnpserver"))
1678 g_application.StartUPnPServer();
1680 g_application.StopUPnPServer();
1683 else if (strSetting.Equals("services.upnprenderer"))
1686 if (g_guiSettings.GetBool("services.upnprenderer"))
1687 g_application.StartUPnPRenderer();
1689 g_application.StopUPnPRenderer();
1692 else if (strSetting.Equals("services.esenabled"))
1694 #ifdef HAS_EVENT_SERVER
1695 if (g_guiSettings.GetBool("services.esenabled"))
1697 if (!g_application.StartEventServer())
1699 CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33102), "", g_localizeStrings.Get(33100), "");
1700 g_guiSettings.SetBool("services.esenabled", false);
1701 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
1702 if (pControl) pControl->SetEnabled(false);
1707 if (!g_application.StopEventServer(true, true))
1709 g_guiSettings.SetBool("services.esenabled", true);
1710 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
1711 if (pControl) pControl->SetEnabled(true);
1716 if (g_guiSettings.GetBool("services.esenabled"))
1718 if (!g_application.StartJSONRPCServer())
1719 CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33103), "", g_localizeStrings.Get(33100), "");
1722 g_application.StopJSONRPCServer(false);
1725 else if (strSetting.Equals("services.esport"))
1727 #ifdef HAS_EVENT_SERVER
1728 ValidatePortNumber(pSettingControl, "9777", "9777");
1729 //restart eventserver without asking user
1730 if (g_application.StopEventServer(true, false))
1732 if (!g_application.StartEventServer())
1733 CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33102), "", g_localizeStrings.Get(33100), "");
1735 #if defined(TARGET_DARWIN_OSX)
1736 //reconfigure XBMCHelper for port changes
1737 XBMCHelper::GetInstance().Configure();
1741 else if (strSetting.Equals("services.esallinterfaces"))
1743 #ifdef HAS_EVENT_SERVER
1744 if (g_guiSettings.GetBool("services.esenabled"))
1746 if (g_application.StopEventServer(true, true))
1748 if (!g_application.StartEventServer())
1749 CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33102), "", g_localizeStrings.Get(33100), "");
1753 g_guiSettings.SetBool("services.esenabled", true);
1754 CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
1755 if (pControl) pControl->SetEnabled(true);
1760 if (g_guiSettings.GetBool("services.esenabled"))
1762 if (!g_application.StartJSONRPCServer())
1763 CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33103), "", g_localizeStrings.Get(33100), "");
1766 g_application.StopJSONRPCServer(false);
1769 else if (strSetting.Equals("services.esinitialdelay") ||
1770 strSetting.Equals("services.escontinuousdelay"))
1772 #ifdef HAS_EVENT_SERVER
1773 if (g_guiSettings.GetBool("services.esenabled"))
1775 g_application.RefreshEventServer();
1779 else if (strSetting.Equals("pvrmanager.enabled"))
1781 if (g_guiSettings.GetBool("pvrmanager.enabled"))
1782 g_application.StartPVRManager();
1784 g_application.StopPVRManager();
1786 else if (strSetting.Equals("masterlock.lockcode"))
1788 // Now Prompt User to enter the old and then the new MasterCode!
1789 if(g_passwordManager.SetMasterLockMode())
1791 // We asked for the master password and saved the new one!
1792 // Nothing todo here
1795 else if (strSetting.Equals("network.interface"))
1797 NetworkInterfaceChanged();
1799 #ifdef HAS_LINUX_NETWORK
1800 else if (strSetting.Equals("network.save"))
1802 NetworkAssignment iAssignment;
1803 CStdString sIPAddress;
1804 CStdString sNetworkMask;
1805 CStdString sDefaultGateway;
1806 CStdString sWirelessNetwork;
1807 CStdString sWirelessKey;
1809 EncMode iWirelessEnc;
1810 CStdString ifaceName;
1812 CGUISpinControlEx *ifaceControl = (CGUISpinControlEx *)GetControl(GetSetting("network.interface")->GetID());
1813 ifaceName = ifaceControl->GetLabel();
1814 CNetworkInterface* iface = g_application.getNetwork().GetInterfaceByName(ifaceName);
1816 // Update controls with information
1817 CGUISpinControlEx* pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.assignment")->GetID());
1818 if (pControl1) iAssignment = (NetworkAssignment) pControl1->GetValue();
1819 CGUIButtonControl* pControl2 = (CGUIButtonControl *)GetControl(GetSetting("network.ipaddress")->GetID());
1820 if (pControl2) sIPAddress = pControl2->GetLabel2();
1821 pControl2 = (CGUIButtonControl *)GetControl(GetSetting("network.subnet")->GetID());
1822 if (pControl2) sNetworkMask = pControl2->GetLabel2();
1823 pControl2 = (CGUIButtonControl *)GetControl(GetSetting("network.gateway")->GetID());
1824 if (pControl2) sDefaultGateway = pControl2->GetLabel2();
1825 pControl2 = (CGUIButtonControl *)GetControl(GetSetting("network.dns")->GetID());
1826 if (pControl2) sDns = pControl2->GetLabel2();
1827 pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.enc")->GetID());
1828 if (pControl1) iWirelessEnc = (EncMode) pControl1->GetValue();
1829 pControl2 = (CGUIButtonControl *)GetControl(GetSetting("network.essid")->GetID());
1830 if (pControl2) sWirelessNetwork = pControl2->GetLabel2();
1831 pControl2 = (CGUIButtonControl *)GetControl(GetSetting("network.key")->GetID());
1832 if (pControl2) sWirelessKey = pControl2->GetLabel2();
1834 CGUIDialogProgress* pDlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
1835 pDlgProgress->SetLine(0, "");
1836 pDlgProgress->SetLine(1, g_localizeStrings.Get(784));
1837 pDlgProgress->SetLine(2, "");
1838 pDlgProgress->StartModal();
1839 pDlgProgress->Progress();
1841 std::vector<CStdString> nameServers;
1842 nameServers.push_back(sDns);
1843 g_application.getNetwork().SetNameServers(nameServers);
1844 iface->SetSettings(iAssignment, sIPAddress, sNetworkMask, sDefaultGateway, sWirelessNetwork, sWirelessKey, iWirelessEnc);
1846 pDlgProgress->Close();
1848 if (iAssignment == NETWORK_DISABLED)
1849 CGUIDialogOK::ShowAndGetInput(0, 788, 0, 0);
1850 else if (iface->IsConnected())
1851 CGUIDialogOK::ShowAndGetInput(0, 785, 0, 0);
1853 CGUIDialogOK::ShowAndGetInput(0, 786, 0, 0);
1855 else if (strSetting.Equals("network.essid"))
1857 CGUIDialogAccessPoints *dialog = (CGUIDialogAccessPoints *)g_windowManager.GetWindow(WINDOW_DIALOG_ACCESS_POINTS);
1860 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting("network.interface")->GetID());
1861 dialog->SetInterfaceName(pControl->GetLabel());
1864 if (dialog->WasItemSelected())
1866 CGUIButtonControl* pControl2 = (CGUIButtonControl *)GetControl(GetSetting("network.essid")->GetID());
1867 if (pControl2) pControl2->SetLabel2(dialog->GetSelectedAccessPointEssId());
1868 pControl = (CGUISpinControlEx *)GetControl(GetSetting("network.enc")->GetID());
1869 if (pControl) pControl->SetValue(dialog->GetSelectedAccessPointEncMode());
1875 else if (strSetting.Equals("locale.timezonecountry"))
1877 CGUISpinControlEx *pControlCountry = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1878 CStdString country = pControlCountry->GetCurrentLabel();
1880 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting("locale.timezone")->GetID());
1882 vector<CStdString> timezones = g_timezone.GetTimezonesByCountry(country);
1883 for (unsigned int i=0; i < timezones.size(); i++)
1885 pControl->AddLabel(timezones[i], i);
1888 g_timezone.SetTimezone(pControl->GetLabel());
1889 g_guiSettings.SetString("locale.timezonecountry",pControlCountry->GetLabel().c_str());
1891 CGUISpinControlEx *tzControl = (CGUISpinControlEx *)GetControl(GetSetting("locale.timezone")->GetID());
1892 g_guiSettings.SetString("locale.timezone", tzControl->GetLabel().c_str());
1894 CDateTime::ResetTimezoneBias();
1896 else if (strSetting.Equals("locale.timezone"))
1898 CGUISpinControlEx *tzControl = (CGUISpinControlEx *)GetControl(GetSetting("locale.timezone")->GetID());
1899 g_timezone.SetTimezone(tzControl->GetLabel());
1900 g_guiSettings.SetString("locale.timezone", tzControl->GetLabel().c_str());
1902 tzControl = (CGUISpinControlEx *)GetControl(GetSetting("locale.timezonecountry")->GetID());
1903 g_guiSettings.SetString("locale.timezonecountry", tzControl->GetLabel().c_str());
1905 CDateTime::ResetTimezoneBias();
1908 else if (strSetting.Equals("lookandfeel.skinzoom"))
1910 g_windowManager.SendMessage(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_WINDOW_RESIZE);
1912 else if (strSetting.Equals("videolibrary.flattentvshows") ||
1913 strSetting.Equals("videolibrary.removeduplicates") ||
1914 strSetting.Equals("videolibrary.groupmoviesets"))
1916 CUtil::DeleteVideoDatabaseDirectoryCache();
1918 else if (strSetting.Equals("pvrmenu.searchicons") && g_PVRManager.IsStarted())
1920 g_PVRManager.SearchMissingChannelIcons();
1922 else if (strSetting.Equals("pvrmanager.resetdb"))
1924 if (g_PVRManager.CheckParentalPIN(g_localizeStrings.Get(19262).c_str()) &&
1925 CGUIDialogYesNo::ShowAndGetInput(19098, 19186, 750, 0))
1927 CDateTime::ResetTimezoneBias();
1928 g_PVRManager.ResetDatabase();
1931 else if (strSetting.Equals("epg.resetepg"))
1933 if (CGUIDialogYesNo::ShowAndGetInput(19098, 19188, 750, 0))
1935 CDateTime::ResetTimezoneBias();
1936 g_PVRManager.ResetEPG();
1939 else if (strSetting.Equals("pvrmanager.channelscan") && g_PVRManager.IsStarted())
1941 if (CGUIDialogYesNo::ShowAndGetInput(19098, 19118, 19194, 0))
1942 g_PVRManager.StartChannelScan();
1944 else if (strSetting.Equals("pvrmanager.channelmanager") && g_PVRManager.IsStarted())
1946 CGUIDialogPVRChannelManager *dialog = (CGUIDialogPVRChannelManager *)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_CHANNEL_MANAGER);
1952 else if (strSetting.compare(0, 12, "audiooutput.") == 0)
1954 if (strSetting.Equals("audiooutput.audiodevice"))
1956 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1957 #if defined(TARGET_DARWIN)
1958 g_guiSettings.SetString("audiooutput.audiodevice", pControl->GetCurrentLabel());
1960 g_guiSettings.SetString("audiooutput.audiodevice", m_AnalogAudioSinkMap[pControl->GetCurrentLabel()]);
1963 #if !defined(TARGET_DARWIN)
1964 else if (strSetting.Equals("audiooutput.passthroughdevice"))
1966 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
1967 g_guiSettings.SetString("audiooutput.passthroughdevice", m_DigitalAudioSinkMap[pControl->GetCurrentLabel()]);
1970 else if (strSetting.Equals("audiooutput.guisoundmode"))
1972 CAEFactory::SetSoundMode(g_guiSettings.GetInt("audiooutput.guisoundmode"));
1975 CAEFactory::OnSettingsChange(strSetting);
1977 else if (strSetting.Equals("pvrparental.enabled"))
1979 if (g_guiSettings.GetBool("pvrparental.enabled") && g_guiSettings.GetString("pvrparental.pin").GetLength() == 0)
1981 CStdString newPassword = "";
1982 bool bNewPassword = CGUIDialogNumeric::ShowAndVerifyNewPassword(newPassword);
1985 // password set... save it
1986 g_guiSettings.SetString("pvrparental.pin", newPassword);
1990 // password not set... disable parental
1991 g_guiSettings.SetBool("pvrparental.enabled", false);
1999 void CGUIWindowSettingsCategory::FreeControls()
2001 // clear the category group
2002 CGUIControlGroupList *control = (CGUIControlGroupList *)GetControl(CATEGORY_GROUP_ID);
2005 control->FreeResources();
2006 control->ClearAll();
2008 m_vecSections.clear();
2009 FreeSettingsControls();
2012 void CGUIWindowSettingsCategory::FreeSettingsControls()
2014 // clear the settings group
2015 CGUIControlGroupList *control = (CGUIControlGroupList *)GetControl(SETTINGS_GROUP_ID);
2018 control->FreeResources();
2019 control->ClearAll();
2022 for(int i = 0; (size_t)i < m_vecSettings.size(); i++)
2024 delete m_vecSettings[i];
2026 m_vecSettings.clear();
2029 CGUIControl* CGUIWindowSettingsCategory::AddSetting(CSetting *pSetting, float width, int &iControlID)
2031 if (!pSetting->IsVisible()) return NULL; // not displayed in current session
2032 CBaseSettingControl *pSettingControl = NULL;
2033 CGUIControl *pControl = NULL;
2034 if (pSetting->GetControlType() == CHECKMARK_CONTROL)
2036 pControl = new CGUIRadioButtonControl(*m_pOriginalRadioButton);
2037 if (!pControl) return NULL;
2038 ((CGUIRadioButtonControl *)pControl)->SetLabel(g_localizeStrings.Get(pSetting->GetLabel()));
2039 pControl->SetWidth(width);
2040 pSettingControl = new CRadioButtonSettingControl((CGUIRadioButtonControl *)pControl, iControlID, pSetting);
2042 else if (pSetting->GetControlType() == SPIN_CONTROL_FLOAT || pSetting->GetControlType() == SPIN_CONTROL_INT_PLUS || pSetting->GetControlType() == SPIN_CONTROL_TEXT || pSetting->GetControlType() == SPIN_CONTROL_INT)
2044 pControl = new CGUISpinControlEx(*m_pOriginalSpin);
2045 if (!pControl) return NULL;
2046 pControl->SetWidth(width);
2047 ((CGUISpinControlEx *)pControl)->SetText(g_localizeStrings.Get(pSetting->GetLabel()));
2048 pSettingControl = new CSpinExSettingControl((CGUISpinControlEx *)pControl, iControlID, pSetting);
2050 else if (pSetting->GetControlType() == SEPARATOR_CONTROL && m_pOriginalImage)
2052 pControl = new CGUIImage(*m_pOriginalImage);
2053 if (!pControl) return NULL;
2054 pControl->SetWidth(width);
2055 pSettingControl = new CSeparatorSettingControl((CGUIImage *)pControl, iControlID, pSetting);
2057 else if (pSetting->GetControlType() == EDIT_CONTROL_INPUT ||
2058 pSetting->GetControlType() == EDIT_CONTROL_HIDDEN_INPUT ||
2059 pSetting->GetControlType() == EDIT_CONTROL_MD5_INPUT ||
2060 pSetting->GetControlType() == EDIT_CONTROL_NUMBER_INPUT ||
2061 pSetting->GetControlType() == EDIT_CONTROL_IP_INPUT ||
2062 pSetting->GetControlType() == EDIT_CONTROL_HIDDEN_NUMBER_VERIFY_NEW )
2064 pControl = new CGUIEditControl(*m_pOriginalEdit);
2065 if (!pControl) return NULL;
2066 ((CGUIEditControl *)pControl)->SettingsCategorySetTextAlign(XBFONT_CENTER_Y);
2067 ((CGUIEditControl *)pControl)->SetLabel(g_localizeStrings.Get(pSetting->GetLabel()));
2068 pControl->SetWidth(width);
2069 pSettingControl = new CEditSettingControl((CGUIEditControl *)pControl, iControlID, pSetting);
2071 else if (pSetting->GetControlType() != SEPARATOR_CONTROL) // button control
2073 pControl = new CGUIButtonControl(*m_pOriginalButton);
2074 if (!pControl) return NULL;
2075 ((CGUIButtonControl *)pControl)->SettingsCategorySetTextAlign(XBFONT_CENTER_Y);
2076 ((CGUIButtonControl *)pControl)->SetLabel(g_localizeStrings.Get(pSetting->GetLabel()));
2077 pControl->SetWidth(width);
2078 pSettingControl = new CButtonSettingControl((CGUIButtonControl *)pControl, iControlID, pSetting);
2082 delete pSettingControl;
2085 pControl->SetID(iControlID++);
2086 pControl->SetVisible(true);
2087 CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(SETTINGS_GROUP_ID);
2090 pControl->AllocResources();
2091 group->AddControl(pControl);
2093 m_vecSettings.push_back(pSettingControl);
2097 void CGUIWindowSettingsCategory::FrameMove()
2099 if (m_delayedSetting && m_delayedTimer.GetElapsedMilliseconds() > 3000)
2100 { // we send a thread message so that it's processed the following frame (some settings won't
2101 // like being changed during Render())
2102 CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), GetID());
2103 g_windowManager.SendThreadMessage(message, GetID());
2104 m_delayedTimer.Stop();
2106 CGUIWindow::FrameMove();
2109 void CGUIWindowSettingsCategory::DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions)
2111 // update alpha status of current button
2112 bool bAlphaFaded = false;
2113 CGUIControl *control = GetFirstFocusableControl(CONTROL_START_BUTTONS + m_iSection);
2114 if (control && !control->HasFocus())
2116 if (control->GetControlType() == CGUIControl::GUICONTROL_BUTTON)
2118 control->SetFocus(true);
2119 ((CGUIButtonControl *)control)->SetAlpha(0x80);
2122 else if (control->GetControlType() == CGUIControl::GUICONTROL_TOGGLEBUTTON)
2124 control->SetFocus(true);
2125 ((CGUIButtonControl *)control)->SetSelected(true);
2129 CGUIWindow::DoProcess(currentTime, dirtyregions);
2132 control->SetFocus(false);
2133 if (control->GetControlType() == CGUIControl::GUICONTROL_BUTTON)
2134 ((CGUIButtonControl *)control)->SetAlpha(0xFF);
2136 ((CGUIButtonControl *)control)->SetSelected(false);
2140 void CGUIWindowSettingsCategory::Render()
2142 CGUIWindow::Render();
2145 void CGUIWindowSettingsCategory::FillInSubtitleHeights(CSetting *pSetting, CGUISpinControlEx *pControl)
2147 CSettingInt *pSettingInt = (CSettingInt*)pSetting;
2148 pControl->SetType(SPIN_CONTROL_TYPE_TEXT);
2150 if (CUtil::IsUsingTTFSubtitles())
2151 { // easy - just fill as per usual
2152 CStdString strLabel;
2153 for (int i = pSettingInt->m_iMin; i <= pSettingInt->m_iMax; i += pSettingInt->m_iStep)
2155 if (pSettingInt->m_iFormat > -1)
2157 CStdString strFormat = g_localizeStrings.Get(pSettingInt->m_iFormat);
2158 strLabel.Format(strFormat, i);
2161 strLabel.Format(pSettingInt->m_strFormat, i);
2162 pControl->AddLabel(strLabel, i);
2164 pControl->SetValue(pSettingInt->GetData());
2168 void CGUIWindowSettingsCategory::FillInSubtitleFonts(CSetting *pSetting)
2170 CSettingString *pSettingString = (CSettingString*)pSetting;
2171 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID());
2172 pControl->SetType(SPIN_CONTROL_TYPE_TEXT);
2174 int iCurrentFont = 0;
2179 CFileItemList items;
2180 CFileItemList items2;
2181 CDirectory::GetDirectory("special://home/media/Fonts/", items2);
2183 if (CDirectory::GetDirectory("special://xbmc/media/Fonts/", items))
2185 items.Append(items2);
2186 for (int i = 0; i < items.Size(); ++i)
2188 CFileItemPtr pItem = items[i];
2190 if (!pItem->m_bIsFolder)
2193 if ( !URIUtils::GetExtension(pItem->GetLabel()).Equals(".ttf") ) continue;
2194 if (pItem->GetLabel().Equals(pSettingString->GetData(), false))
2195 iCurrentFont = iFont;
2197 pControl->AddLabel(pItem->GetLabel(), iFont++);
2203 pControl->SetValue(iCurrentFont);
2206 void CGUIWindowSettingsCategory::FillInSkinFonts(CSetting *pSetting)
2208 CBaseSettingControl *setting = GetSetting(pSetting->GetSetting());
2209 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(setting->GetID());
2210 pControl->SetType(SPIN_CONTROL_TYPE_TEXT);
2212 setting->SetDelayed();
2214 m_SkinFontSetIDs.clear();
2215 int iSkinFontSet = 0;
2217 CStdString strPath = g_SkinInfo->GetSkinPath("Font.xml");
2219 CXBMCTinyXML xmlDoc;
2220 if (!xmlDoc.LoadFile(strPath))
2222 CLog::Log(LOGERROR, "Couldn't load %s", strPath.c_str());
2226 TiXmlElement* pRootElement = xmlDoc.RootElement();
2228 CStdString strValue = pRootElement->Value();
2229 if (strValue != CStdString("fonts"))
2231 CLog::Log(LOGERROR, "file %s doesnt start with <fonts>", strPath.c_str());
2235 const TiXmlNode *pChild = pRootElement->FirstChild();
2236 strValue = pChild->Value();
2237 if (strValue == "fontset")
2241 strValue = pChild->Value();
2242 if (strValue == "fontset")
2244 const char* idAttr = ((TiXmlElement*) pChild)->Attribute("id");
2245 const char* idLocAttr = ((TiXmlElement*) pChild)->Attribute("idloc");
2246 const char* unicodeAttr = ((TiXmlElement*) pChild)->Attribute("unicode");
2248 bool isUnicode=(unicodeAttr && stricmp(unicodeAttr, "true") == 0);
2250 bool isAllowed=true;
2251 if (g_langInfo.ForceUnicodeFont() && !isUnicode)
2254 if (idAttr != NULL && isAllowed)
2258 pControl->AddLabel(g_localizeStrings.Get(atoi(idLocAttr)), iSkinFontSet);
2259 m_SkinFontSetIDs[g_localizeStrings.Get(atoi(idLocAttr))] = idAttr;
2263 pControl->AddLabel(idAttr, iSkinFontSet);
2264 m_SkinFontSetIDs[idAttr] = idAttr;
2266 if (strcmpi(idAttr, g_guiSettings.GetString("lookandfeel.font").c_str()) == 0)
2267 pControl->SetValue(iSkinFontSet);
2271 pChild = pChild->NextSibling();
2277 // Since no fontset is defined, there is no selection of a fontset, so disable the component
2278 pControl->AddLabel(g_localizeStrings.Get(13278), 1);
2279 pControl->SetValue(1);
2280 pControl->SetEnabled(false);
2284 void CGUIWindowSettingsCategory::FillInSoundSkins(CSetting *pSetting)
2286 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID());
2287 pControl->SetType(SPIN_CONTROL_TYPE_TEXT);
2289 pControl->SetShowRange(true);
2292 CFileItemList items;
2293 CDirectory::GetDirectory("special://xbmc/sounds/", items);
2294 CDirectory::GetDirectory("special://home/sounds/", items);
2296 int iCurrentSoundSkin = 0;
2298 vector<CStdString> vecSoundSkins;
2300 for (i = 0; i < items.Size(); ++i)
2302 CFileItemPtr pItem = items[i];
2303 if (pItem->m_bIsFolder)
2305 if (strcmpi(pItem->GetLabel().c_str(), ".svn") == 0) continue;
2306 if (strcmpi(pItem->GetLabel().c_str(), "fonts") == 0) continue;
2307 if (strcmpi(pItem->GetLabel().c_str(), "media") == 0) continue;
2308 vecSoundSkins.push_back(pItem->GetLabel());
2312 pControl->AddLabel(g_localizeStrings.Get(474), iSoundSkin++); // Off
2313 pControl->AddLabel(g_localizeStrings.Get(15109), iSoundSkin++); // Skin Default
2315 if (g_guiSettings.GetString("lookandfeel.soundskin")=="SKINDEFAULT")
2316 iCurrentSoundSkin=1;
2318 sort(vecSoundSkins.begin(), vecSoundSkins.end(), sortstringbyname());
2319 for (i = 0; i < (int) vecSoundSkins.size(); ++i)
2321 CStdString strSkin = vecSoundSkins[i];
2322 if (strcmpi(strSkin.c_str(), g_guiSettings.GetString("lookandfeel.soundskin").c_str()) == 0)
2324 iCurrentSoundSkin = iSoundSkin;
2326 pControl->AddLabel(strSkin, iSoundSkin++);
2328 pControl->SetValue(iCurrentSoundSkin);
2332 void CGUIWindowSettingsCategory::FillInCharSets(CSetting *pSetting)
2334 CSettingString *pSettingString = (CSettingString*)pSetting;
2335 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID());
2336 pControl->SetType(SPIN_CONTROL_TYPE_TEXT);
2338 int iCurrentCharset = 0;
2339 vector<CStdString> vecCharsets = g_charsetConverter.getCharsetLabels();
2341 CStdString strCurrentCharsetLabel="DEFAULT";
2342 if (pSettingString->GetData()!="DEFAULT")
2343 strCurrentCharsetLabel = g_charsetConverter.getCharsetLabelByName(pSettingString->GetData());
2345 sort(vecCharsets.begin(), vecCharsets.end(), sortstringbyname());
2347 vecCharsets.insert(vecCharsets.begin(), g_localizeStrings.Get(13278)); // "Default"
2349 bool bIsAuto=(pSettingString->GetData()=="DEFAULT");
2351 for (int i = 0; i < (int) vecCharsets.size(); ++i)
2353 CStdString strCharsetLabel = vecCharsets[i];
2355 if (!bIsAuto && strCharsetLabel == strCurrentCharsetLabel)
2356 iCurrentCharset = i;
2358 pControl->AddLabel(strCharsetLabel, i);
2361 pControl->SetValue(iCurrentCharset);
2364 DisplayMode CGUIWindowSettingsCategory::FillInScreens(CStdString strSetting, RESOLUTION res)
2367 if (res == RES_WINDOW)
2370 mode = g_settings.m_ResInfo[res].iScreen;
2372 // we expect "videoscreen.screen" but it might be hidden on some platforms,
2373 // so check that we actually have a visable control.
2374 CBaseSettingControl *control = GetSetting(strSetting);
2377 control->SetDelayed();
2378 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(control->GetID());
2381 CStdString strScreen;
2382 if (g_advancedSettings.m_canWindowed)
2383 pControl->AddLabel(g_localizeStrings.Get(242), -1);
2385 for (int idx = 0; idx < g_Windowing.GetNumScreens(); idx++)
2387 strScreen.Format(g_localizeStrings.Get(241), g_settings.m_ResInfo[RES_DESKTOP + idx].iScreen + 1);
2388 pControl->AddLabel(strScreen, g_settings.m_ResInfo[RES_DESKTOP + idx].iScreen);
2390 pControl->SetValue(mode);
2391 g_guiSettings.SetInt("videoscreen.screen", mode);
2397 void CGUIWindowSettingsCategory::FillInResolutions(CStdString strSetting, DisplayMode mode, RESOLUTION res, bool UserChange)
2399 CBaseSettingControl *control = GetSetting(strSetting);
2400 control->SetDelayed();
2401 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(control->GetID());
2405 RESOLUTION spinres = RES_INVALID; // index of the resolution in the spinner that has same screen/width/height as res
2407 if (mode == DM_WINDOWED)
2409 pControl->AddLabel(g_localizeStrings.Get(242), RES_WINDOW);
2410 spinres = RES_WINDOW;
2414 vector<RESOLUTION_WHR> resolutions = g_Windowing.ScreenResolutions(mode);
2416 for (unsigned int idx = 0; idx < resolutions.size(); idx++)
2419 strRes.Format("%dx%d%s", resolutions[idx].width, resolutions[idx].height,
2420 (resolutions[idx].interlaced == D3DPRESENTFLAG_INTERLACED) ? "i" : "p");
2421 pControl->AddLabel(strRes, resolutions[idx].ResInfo_Index);
2423 RESOLUTION_INFO res1 = g_settings.m_ResInfo[res];
2424 RESOLUTION_INFO res2 = g_settings.m_ResInfo[resolutions[idx].ResInfo_Index];
2425 if ( res1.iScreen == res2.iScreen
2426 && res1.iScreenWidth == res2.iScreenWidth
2427 && res1.iScreenHeight == res2.iScreenHeight
2428 && (res1.dwFlags & D3DPRESENTFLAG_INTERLACED) == (res2.dwFlags & D3DPRESENTFLAG_INTERLACED))
2429 spinres = (RESOLUTION) resolutions[idx].ResInfo_Index;
2435 // Auto-select the windowed or desktop resolution of the screen
2436 int autoresolution = RES_DESKTOP;
2437 if (mode == DM_WINDOWED)
2439 autoresolution = RES_WINDOW;
2443 for (int idx=0; idx < g_Windowing.GetNumScreens(); idx++)
2444 if (g_settings.m_ResInfo[RES_DESKTOP + idx].iScreen == mode)
2446 autoresolution = RES_DESKTOP + idx;
2450 pControl->SetValue(autoresolution);
2453 FillInRefreshRates("videoscreen.screenmode", (RESOLUTION) autoresolution, true);
2457 // select the entry equivalent to the resolution passed by the res parameter
2458 pControl->SetValue(spinres);
2462 void CGUIWindowSettingsCategory::FillInRefreshRates(CStdString strSetting, RESOLUTION res, bool UserChange)
2464 // The only meaningful parts of res here are iScreen, iScreenWidth, iScreenHeight
2466 vector<REFRESHRATE> refreshrates;
2467 if (res > RES_WINDOW)
2468 refreshrates = g_Windowing.RefreshRates(g_settings.m_ResInfo[res].iScreen,
2469 g_settings.m_ResInfo[res].iScreenWidth,
2470 g_settings.m_ResInfo[res].iScreenHeight,
2471 g_settings.m_ResInfo[res].dwFlags);
2473 // The control setting doesn't exist when not in standalone mode, don't manipulate it
2474 CBaseSettingControl *control = GetSetting(strSetting);
2475 CGUISpinControlEx *pControl= NULL;
2480 control->SetDelayed();
2481 pControl = (CGUISpinControlEx *)GetControl(control->GetID());
2484 if (res == RES_WINDOW)
2486 pControl->AddLabel(g_localizeStrings.Get(242), RES_WINDOW);
2490 for (unsigned int idx = 0; idx < refreshrates.size(); idx++)
2493 strRR.Format("%.02f", refreshrates[idx].RefreshRate);
2494 pControl->AddLabel(strRR, refreshrates[idx].ResInfo_Index);
2502 RESOLUTION newresolution;
2503 if (res == RES_WINDOW)
2504 newresolution = RES_WINDOW;
2506 newresolution = (RESOLUTION) g_Windowing.DefaultRefreshRate(g_settings.m_ResInfo[res].iScreen, refreshrates).ResInfo_Index;
2509 pControl->SetValue(newresolution);
2511 OnRefreshRateChanged(newresolution);
2516 pControl->SetValue(res);
2520 void CGUIWindowSettingsCategory::OnRefreshRateChanged(RESOLUTION nextRes)
2522 RESOLUTION lastRes = g_graphicsContext.GetVideoResolution();
2523 bool cancelled = false;
2525 g_guiSettings.SetResolution(nextRes);
2526 g_graphicsContext.SetVideoResolution(nextRes);
2528 if (!CGUIDialogYesNo::ShowAndGetInput(13110, 13111, 20022, 20022, -1, -1, cancelled, 10000))
2530 g_guiSettings.SetResolution(lastRes);
2531 g_graphicsContext.SetVideoResolution(lastRes);
2533 DisplayMode mode = FillInScreens("videoscreen.screen", lastRes);
2534 FillInResolutions("videoscreen.resolution", mode, lastRes, false);
2535 FillInRefreshRates("videoscreen.screenmode", lastRes, false);
2539 void CGUIWindowSettingsCategory::FillInLanguages(CSetting *pSetting, const std::vector<CStdString> &languages /* = std::vector<CStdString>() */, const std::vector<CStdString> &languageKeys /* = std::vector<CStdString>() */)
2541 CSettingString *pSettingString = (CSettingString *)pSetting;
2542 CBaseSettingControl *setting = GetSetting(pSetting->GetSetting());
2543 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(setting->GetID());
2547 CFileItemList items;
2548 CDirectory::GetDirectory("special://xbmc/language/", items);
2550 int iCurrentLang = 0;
2551 vector<CStdString> vecLanguage;
2552 for (int i = 0; i < items.Size(); ++i)
2554 CFileItemPtr pItem = items[i];
2555 if (pItem->m_bIsFolder)
2557 if (strcmpi(pItem->GetLabel().c_str(), ".svn") == 0) continue;
2558 if (strcmpi(pItem->GetLabel().c_str(), "fonts") == 0) continue;
2559 if (strcmpi(pItem->GetLabel().c_str(), "media") == 0) continue;
2560 vecLanguage.push_back(pItem->GetLabel());
2564 sort(vecLanguage.begin(), vecLanguage.end(), sortstringbyname());
2565 // Add language options passed by parameter at the beginning
2566 if (languages.size() > 0)
2567 vecLanguage.insert(vecLanguage.begin(), languages.begin(), languages.begin() + languages.size());
2568 for (unsigned int i = 0; i < vecLanguage.size(); ++i)
2570 CStdString strLanguage = vecLanguage[i];
2571 if ((i < languageKeys.size() && strcmpi(languageKeys[i].c_str(), pSettingString->GetData().c_str()) == 0) ||
2572 strcmpi(strLanguage.c_str(), pSettingString->GetData().c_str()) == 0)
2574 pControl->AddLabel(strLanguage, i);
2577 pControl->SetValue(iCurrentLang);
2580 void CGUIWindowSettingsCategory::FillInRegions(CSetting *pSetting)
2582 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID());
2583 pControl->SetType(SPIN_CONTROL_TYPE_TEXT);
2586 int iCurrentRegion=0;
2587 CStdStringArray regions;
2588 g_langInfo.GetRegionNames(regions);
2590 CStdString strCurrentRegion=g_langInfo.GetCurrentRegion();
2592 sort(regions.begin(), regions.end(), sortstringbyname());
2594 for (int i = 0; i < (int) regions.size(); ++i)
2596 const CStdString& strRegion = regions[i];
2598 if (strRegion == strCurrentRegion)
2601 pControl->AddLabel(strRegion, i);
2604 pControl->SetValue(iCurrentRegion);
2607 CBaseSettingControl *CGUIWindowSettingsCategory::GetSetting(const CStdString &strSetting)
2609 for (unsigned int i = 0; i < m_vecSettings.size(); i++)
2611 if (m_vecSettings[i]->GetSetting()->GetSetting() == strSetting)
2612 return m_vecSettings[i];
2617 void CGUIWindowSettingsCategory::FillInSkinThemes(CSetting *pSetting)
2619 // There is a default theme (just Textures.xpr/xbt)
2620 // any other *.xpr|*.xbt files are additional themes on top of this one.
2621 CSettingString *pSettingString = (CSettingString *)pSetting;
2622 CBaseSettingControl *setting = GetSetting(pSetting->GetSetting());
2623 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(setting->GetID());
2624 CStdString strSettingString = g_guiSettings.GetString("lookandfeel.skintheme");
2625 setting->SetDelayed();
2627 // Clear and add. the Default Label
2629 pControl->SetShowRange(true);
2630 pControl->AddLabel(g_localizeStrings.Get(15109), 0); // "SKINDEFAULT" The standard Textures.xpr/xbt will be used
2632 CStdString strDefaultTheme = pSettingString->GetData();
2634 // Search for Themes in the Current skin!
2635 vector<CStdString> vecTheme;
2636 CUtil::GetSkinThemes(vecTheme);
2638 // Remove the extension from the current Theme (backward compat)
2639 URIUtils::RemoveExtension(strSettingString);
2641 // Sort the Themes for GUI and list them
2642 int iCurrentTheme = 0;
2643 for (int i = 0; i < (int) vecTheme.size(); ++i)
2645 CStdString strTheme = vecTheme[i];
2646 // Is the Current Theme our Used Theme! If yes set the ID!
2647 if (strTheme.CompareNoCase(strSettingString) == 0 )
2648 iCurrentTheme = i + 1; // 1: #of Predefined Theme [Label]
2649 pControl->AddLabel(strTheme, i + 1);
2651 // Set the Choosen Theme
2652 pControl->SetValue(iCurrentTheme);
2655 void CGUIWindowSettingsCategory::FillInSkinColors(CSetting *pSetting)
2657 // There is a default theme (just defaults.xml)
2658 // any other *.xml files are additional color themes on top of this one.
2659 CBaseSettingControl *setting = GetSetting(pSetting->GetSetting());
2660 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(setting->GetID());
2661 CStdString strSettingString = g_guiSettings.GetString("lookandfeel.skincolors");
2662 setting->SetDelayed();
2664 // Clear and add. the Default Label
2666 pControl->SetShowRange(true);
2667 pControl->AddLabel(g_localizeStrings.Get(15109), 0); // "SKINDEFAULT"! The standard defaults.xml will be used!
2669 // Search for colors in the Current skin!
2670 vector<CStdString> vecColors;
2673 URIUtils::AddFileToFolder(g_SkinInfo->Path(),"colors",strPath);
2675 CFileItemList items;
2676 CDirectory::GetDirectory(CSpecialProtocol::TranslatePathConvertCase(strPath), items, ".xml");
2677 // Search for Themes in the Current skin!
2678 for (int i = 0; i < items.Size(); ++i)
2680 CFileItemPtr pItem = items[i];
2681 if (!pItem->m_bIsFolder && pItem->GetLabel().CompareNoCase("defaults.xml") != 0)
2682 { // not the default one
2683 CStdString strLabel = pItem->GetLabel();
2684 vecColors.push_back(strLabel.Mid(0, strLabel.size() - 4));
2687 sort(vecColors.begin(), vecColors.end(), sortstringbyname());
2689 // Remove the .xml extension from the Themes
2690 if (URIUtils::GetExtension(strSettingString) == ".xml")
2691 URIUtils::RemoveExtension(strSettingString);
2693 int iCurrentColor = 0;
2694 for (int i = 0; i < (int) vecColors.size(); ++i)
2696 CStdString strColor = vecColors[i];
2697 // Is the Current Theme our Used Theme! If yes set the ID!
2698 if (strColor.CompareNoCase(strSettingString) == 0 )
2699 iCurrentColor = i + 1; // 1: #of Predefined Theme [Label]
2700 pControl->AddLabel(strColor, i + 1);
2702 // Set the Choosen Theme
2703 pControl->SetValue(iCurrentColor);
2706 void CGUIWindowSettingsCategory::FillInStartupWindow(CSetting *pSetting)
2708 CSettingInt *pSettingInt = (CSettingInt*)pSetting;
2709 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID());
2712 const vector<CSkinInfo::CStartupWindow> &startupWindows = g_SkinInfo->GetStartupWindows();
2714 // TODO: How should we localize this?
2715 // In the long run there is no way to do it really without the skin having some
2716 // translation information built in to it, which isn't really feasible.
2718 // Alternatively we could lookup the strings in the english strings file to get
2719 // their id and then get the string from that
2721 // easier would be to have the skinner use the "name" as the label number.
2723 // eg <window id="0">513</window>
2725 bool currentSettingFound(false);
2726 for (vector<CSkinInfo::CStartupWindow>::const_iterator it = startupWindows.begin(); it != startupWindows.end(); it++)
2728 CStdString windowName((*it).m_name);
2729 if (StringUtils::IsNaturalNumber(windowName))
2730 windowName = g_localizeStrings.Get(atoi(windowName.c_str()));
2731 int windowID((*it).m_id);
2732 pControl->AddLabel(windowName, windowID);
2733 if (pSettingInt->GetData() == windowID)
2734 currentSettingFound = true;
2737 // ok, now check whether our current option is one of these
2738 // and set it's value
2739 if (!currentSettingFound)
2740 { // nope - set it to the "default" option - the first one
2741 pSettingInt->SetData(startupWindows[0].m_id);
2743 pControl->SetValue(pSettingInt->GetData());
2746 void CGUIWindowSettingsCategory::OnInitWindow()
2748 m_strOldTrackFormat = g_guiSettings.GetString("musicfiles.trackformat");
2749 m_strOldTrackFormatRight = g_guiSettings.GetString("musicfiles.trackformatright");
2751 CGUIWindow::OnInitWindow();
2754 void CGUIWindowSettingsCategory::FillInViewModes(CSetting *pSetting, int windowID)
2756 CSettingInt *pSettingInt = (CSettingInt*)pSetting;
2757 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID());
2758 pControl->AddLabel("Auto", DEFAULT_VIEW_AUTO);
2761 CGUIWindow *window = g_windowManager.GetWindow(windowID);
2764 window->Initialize();
2765 for (int i = 50; i < 60; i++)
2767 CGUIBaseContainer *control = (CGUIBaseContainer *)window->GetControl(i);
2770 int type = (control->GetType() << 16) | i;
2771 pControl->AddLabel(control->GetLabel(), type);
2772 if (type == pSettingInt->GetData())
2774 else if ((type >> 16) == (pSettingInt->GetData() >> 16))
2781 pSettingInt->SetData(foundType ? foundType : (DEFAULT_VIEW_AUTO));
2782 pControl->SetValue(pSettingInt->GetData());
2785 void CGUIWindowSettingsCategory::FillInSortMethods(CSetting *pSetting, int windowID)
2787 CSettingInt *pSettingInt = (CSettingInt*)pSetting;
2788 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID());
2789 CFileItemList items("C:");
2790 CGUIViewState *state = CGUIViewState::GetViewState(windowID, items);
2794 vector< pair<int,int> > sortMethods;
2795 state->GetSortMethods(sortMethods);
2796 for (unsigned int i = 0; i < sortMethods.size(); i++)
2798 pControl->AddLabel(g_localizeStrings.Get(sortMethods[i].second), sortMethods[i].first);
2799 if (sortMethods[i].first == pSettingInt->GetData())
2802 if (!found && sortMethods.size())
2803 pSettingInt->SetData(sortMethods[0].first);
2805 pControl->SetValue(pSettingInt->GetData());
2809 void CGUIWindowSettingsCategory::FillInNetworkInterfaces(CSetting *pSetting, float groupWidth, int &iControlID)
2811 CGUISpinControlEx *pControl = (CGUISpinControlEx *)AddSetting(pSetting, groupWidth, iControlID);
2814 // query list of interfaces
2815 vector<CStdString> vecInterfaces;
2816 std::vector<CNetworkInterface*>& ifaces = g_application.getNetwork().GetInterfaceList();
2817 std::vector<CNetworkInterface*>::const_iterator iter = ifaces.begin();
2818 while (iter != ifaces.end())
2820 CNetworkInterface* iface = *iter;
2821 vecInterfaces.push_back(iface->GetName());
2824 sort(vecInterfaces.begin(), vecInterfaces.end(), sortstringbyname());
2827 for (unsigned int i = 0; i < vecInterfaces.size(); ++i)
2828 pControl->AddLabel(vecInterfaces[i], iInterface++);
2831 void CGUIWindowSettingsCategory::FillInEpgGuideView(CSetting *pSetting)
2833 CSettingInt *pSettingInt = (CSettingInt*)pSetting;
2834 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID());
2837 pControl->AddLabel(g_localizeStrings.Get(19029), GUIDE_VIEW_CHANNEL);
2838 pControl->AddLabel(g_localizeStrings.Get(19030), GUIDE_VIEW_NOW);
2839 pControl->AddLabel(g_localizeStrings.Get(19031), GUIDE_VIEW_NEXT);
2840 pControl->AddLabel(g_localizeStrings.Get(19032), GUIDE_VIEW_TIMELINE);
2842 pControl->SetValue(pSettingInt->GetData());
2845 void CGUIWindowSettingsCategory::FillInPvrStartLastChannel(CSetting *pSetting)
2847 CSettingInt *pSettingInt = (CSettingInt*)pSetting;
2848 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID());
2851 pControl->AddLabel(g_localizeStrings.Get(106), START_LAST_CHANNEL_OFF);
2852 pControl->AddLabel(g_localizeStrings.Get(19190), START_LAST_CHANNEL_MIN);
2853 pControl->AddLabel(g_localizeStrings.Get(107), START_LAST_CHANNEL_ON);
2855 pControl->SetValue(pSettingInt->GetData());
2858 void CGUIWindowSettingsCategory::FillInAudioDevices(CSetting* pSetting, bool Passthrough)
2860 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID());
2863 CStdString currentDevice = Passthrough ? g_guiSettings.GetString("audiooutput.passthroughdevice") : g_guiSettings.GetString("audiooutput.audiodevice");
2867 m_DigitalAudioSinkMap.clear();
2868 m_DigitalAudioSinkMap["Error - no devices found"] = "null:";
2872 m_AnalogAudioSinkMap.clear();
2873 m_AnalogAudioSinkMap["Error - no devices found"] = "null:";
2876 int numberSinks = 0;
2878 int selectedValue = -1;
2879 AEDeviceList sinkList;
2880 CAEFactory::EnumerateOutputDevices(sinkList, Passthrough);
2881 #if !defined(TARGET_DARWIN)
2882 if (sinkList.size()==0)
2884 pControl->AddLabel("Error - no devices found", 0);
2891 AEDeviceList::const_iterator iter = sinkList.begin();
2892 for (int i=0; iter != sinkList.end(); iter++)
2894 CStdString label = (*iter).first;
2895 CStdString sink = (*iter).second;
2896 pControl->AddLabel(label.c_str(), i);
2898 if (currentDevice.Equals(sink))
2902 m_DigitalAudioSinkMap[label] = sink;
2904 m_AnalogAudioSinkMap[label] = sink;
2909 numberSinks = sinkList.size();
2910 #if !defined(TARGET_DARWIN)
2914 if (selectedValue < 0)
2916 CLog::Log(LOGWARNING, "Failed to find previously selected audio sink");
2917 pControl->AddLabel(currentDevice, numberSinks);
2918 pControl->SetValue(numberSinks);
2921 pControl->SetValue(selectedValue);
2924 void CGUIWindowSettingsCategory::NetworkInterfaceChanged(void)
2927 NetworkAssignment iAssignment;
2928 CStdString sIPAddress;
2929 CStdString sNetworkMask;
2930 CStdString sDefaultGateway;
2931 CStdString sWirelessNetwork;
2932 CStdString sWirelessKey;
2933 EncMode iWirelessEnc;
2935 CStdString ifaceName;
2937 // Get network information
2938 CGUISpinControlEx *ifaceControl = (CGUISpinControlEx *)GetControl(GetSetting("network.interface")->GetID());
2939 ifaceName = ifaceControl->GetLabel();
2940 CNetworkInterface* iface = g_application.getNetwork().GetInterfaceByName(ifaceName);
2941 iface->GetSettings(iAssignment, sIPAddress, sNetworkMask, sDefaultGateway, sWirelessNetwork, sWirelessKey, iWirelessEnc);
2942 bIsWireless = iface->IsWireless();
2945 std::vector<CStdString> dnss = g_application.getNetwork().GetNameServers();
2946 if (dnss.size() >= 1)
2949 // Update controls with information
2950 CGUISpinControlEx* pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.assignment")->GetID());
2951 if (pControl1) pControl1->SetValue(iAssignment);
2952 GetSetting("network.dns")->GetSetting()->FromString(dns);
2953 if (iAssignment == NETWORK_STATIC || iAssignment == NETWORK_DISABLED)
2955 GetSetting("network.ipaddress")->GetSetting()->FromString(sIPAddress);
2956 GetSetting("network.subnet")->GetSetting()->FromString(sNetworkMask);
2957 GetSetting("network.gateway")->GetSetting()->FromString(sDefaultGateway);
2961 GetSetting("network.ipaddress")->GetSetting()->FromString(iface->GetCurrentIPAddress());
2962 GetSetting("network.subnet")->GetSetting()->FromString(iface->GetCurrentNetmask());
2963 GetSetting("network.gateway")->GetSetting()->FromString(iface->GetCurrentDefaultGateway());
2966 pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.enc")->GetID());
2967 if (pControl1) pControl1->SetValue(iWirelessEnc);
2971 GetSetting("network.essid")->GetSetting()->FromString(sWirelessNetwork);
2972 GetSetting("network.key")->GetSetting()->FromString(sWirelessKey);
2976 GetSetting("network.essid")->GetSetting()->FromString("");
2977 GetSetting("network.key")->GetSetting()->FromString("");
2982 void CGUIWindowSettingsCategory::ValidatePortNumber(CBaseSettingControl* pSettingControl, const CStdString& userPort, const CStdString& privPort, bool listening/*=true*/)
2984 CSettingString *pSetting = (CSettingString *)pSettingControl->GetSetting();
2985 // check that it's a valid port
2986 int port = atoi(pSetting->GetData().c_str());
2988 if (listening && !CUtil::CanBindPrivileged() && (port < 1024 || port > 65535))
2990 CGUIDialogOK::ShowAndGetInput(257, 850, 852, -1);
2991 pSetting->SetData(userPort.c_str());
2995 if (port <= 0 || port > 65535)
2997 CGUIDialogOK::ShowAndGetInput(257, 850, 851, -1);
2998 pSetting->SetData(privPort.c_str());