This repository has been archived by the owner on Sep 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 75
/
Settings.cpp
1930 lines (1692 loc) · 65.8 KB
/
Settings.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) 2005-2008 Team XBMC
* http://www.xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include "system.h"
#include "Settings.h"
#include "AdvancedSettings.h"
#include "Application.h"
#include "input/KeyboardLayoutConfiguration.h"
#include "Util.h"
#include "URL.h"
#include "guilib/GUIFontManager.h"
#include "input/ButtonTranslator.h"
#include "utils/XMLUtils.h"
#include "PasswordManager.h"
#include "utils/RegExp.h"
#include "GUIPassword.h"
#include "GUIInfoManager.h"
#include "filesystem/MultiPathDirectory.h"
#include "filesystem/SpecialProtocol.h"
#include "guilib/GUIBaseContainer.h" // for VIEW_TYPE enum
#include "guilib/GUIWindowManager.h"
#include "dialogs/GUIDialogYesNo.h"
#include "filesystem/Directory.h"
#include "FileItem.h"
#include "LangInfo.h"
#include "guilib/LocalizeStrings.h"
#include "utils/StringUtils.h"
#include "utils/SystemInfo.h"
#ifdef _WIN32
#include "win32/WIN32Util.h"
#endif
#if defined(_LINUX) && defined(HAS_FILESYSTEM_SMB)
#include "filesystem/SMBDirectory.h"
#endif
#include "cores/playercorefactory/PlayerCoreFactory.h"
#include "utils/FileUtils.h"
#include "utils/URIUtils.h"
#include "input/MouseStat.h"
#include "filesystem/File.h"
#include "filesystem/DirectoryCache.h"
using namespace std;
using namespace XFILE;
CSettings::CSettings(void)
{
}
void CSettings::Initialize()
{
RESOLUTION_INFO res;
vector<RESOLUTION_INFO>::iterator it = m_ResInfo.begin();
m_ResInfo.insert(it, RES_CUSTOM, res);
for (int i = RES_HDTV_1080i; i <= RES_PAL60_16x9; i++)
{
g_graphicsContext.ResetScreenParameters((RESOLUTION)i);
g_graphicsContext.ResetOverscan((RESOLUTION)i, m_ResInfo[i].Overscan);
}
m_videoStacking = false;
m_bMyMusicSongInfoInVis = true; // UNUSED - depreciated.
m_bMyMusicSongThumbInVis = false; // used for music info in vis screen
m_bMyMusicPlaylistRepeat = false;
m_bMyMusicPlaylistShuffle = false;
m_bMyVideoPlaylistRepeat = false;
m_bMyVideoPlaylistShuffle = false;
m_bMyVideoNavFlatten = false;
m_bStartVideoWindowed = false;
m_bAddonAutoUpdate = true;
m_bAddonNotifications = true;
m_bAddonForeignFilter = false;
m_fVolumeLevel = 1.0f;
m_bMute = false;
m_fZoomAmount = 1.0f;
m_fPixelRatio = 1.0f;
m_bNonLinStretch = false;
m_pictureExtensions = ".png|.jpg|.jpeg|.bmp|.gif|.ico|.tif|.tiff|.tga|.pcx|.cbz|.zip|.cbr|.rar|.m3u|.dng|.nef|.cr2|.crw|.orf|.arw|.erf|.3fr|.dcr|.x3f|.mef|.raf|.mrw|.pef|.sr2|.rss";
m_musicExtensions = ".nsv|.m4a|.flac|.aac|.strm|.pls|.rm|.rma|.mpa|.wav|.wma|.ogg|.mp3|.mp2|.m3u|.mod|.amf|.669|.dmf|.dsm|.far|.gdm|.imf|.it|.m15|.med|.okt|.s3m|.stm|.sfx|.ult|.uni|.xm|.sid|.ac3|.dts|.cue|.aif|.aiff|.wpl|.ape|.mac|.mpc|.mp+|.mpp|.shn|.zip|.rar|.wv|.nsf|.spc|.gym|.adx|.dsp|.adp|.ymf|.ast|.afc|.hps|.xsp|.xwav|.waa|.wvs|.wam|.gcm|.idsp|.mpdsp|.mss|.spt|.rsd|.mid|.kar|.sap|.cmc|.cmr|.dmc|.mpt|.mpd|.rmt|.tmc|.tm8|.tm2|.oga|.url|.pxml|.tta|.rss|.cm3|.cms|.dlt|.brstm|.wtv|.mka";
m_videoExtensions = ".m4v|.3g2|.3gp|.nsv|.tp|.ts|.ty|.strm|.pls|.rm|.rmvb|.m3u|.ifo|.mov|.qt|.divx|.xvid|.bivx|.vob|.nrg|.img|.iso|.pva|.wmv|.asf|.asx|.ogm|.m2v|.avi|.bin|.dat|.mpg|.mpeg|.mp4|.mkv|.avc|.vp3|.svq3|.nuv|.viv|.dv|.fli|.flv|.rar|.001|.wpl|.zip|.vdr|.dvr-ms|.xsp|.mts|.m2t|.m2ts|.evo|.ogv|.sdp|.avs|.rec|.url|.pxml|.vc1|.h264|.rcv|.rss|.mpls|.webm|.bdmv|.wtv";
m_discStubExtensions = ".disc";
// internal music extensions
m_musicExtensions += "|.sidstream|.oggstream|.nsfstream|.asapstream|.cdda";
#if defined(TARGET_DARWIN)
CStdString logDir = getenv("HOME");
logDir += "/Library/Logs/";
m_logFolder = logDir;
#else
m_logFolder = "special://home/"; // log file location
#endif
// defaults for scanning
m_bMyMusicIsScanning = false;
iAdditionalSubtitleDirectoryChecked = 0;
m_iMyMusicStartWindow = WINDOW_MUSIC_FILES;
m_iVideoStartWindow = WINDOW_VIDEO_FILES;
m_watchMode["movies"] = VIDEO_SHOW_ALL;
m_watchMode["tvshows"] = VIDEO_SHOW_ALL;
m_watchMode["musicvideos"] = VIDEO_SHOW_ALL;
m_iSystemTimeTotalUp = 0;
m_HttpApiBroadcastLevel = 0;
m_HttpApiBroadcastPort = 8278;
m_userAgent = g_sysinfo.GetUserAgent();
m_usingLoginScreen = false;
m_lastUsedProfile = 0;
m_currentProfile = 0;
m_nextIdProfile = 0;
}
CSettings::~CSettings(void)
{
m_ResInfo.clear();
}
void CSettings::Save() const
{
if (g_application.m_bStop)
{
//don't save settings when we're busy stopping the application
//a lot of screens try to save settings on deinit and deinit is called
//for every screen when the application is stopping.
return ;
}
if (!SaveSettings(GetSettingsFile()))
{
CLog::Log(LOGERROR, "Unable to save settings to %s", GetSettingsFile().c_str());
}
}
bool CSettings::Reset()
{
CLog::Log(LOGINFO, "Resetting settings");
CFile::Delete(GetSettingsFile());
Save();
return LoadSettings(GetSettingsFile());
}
bool CSettings::Load()
{
CSpecialProtocol::SetProfilePath(GetProfileUserDataFolder());
CLog::Log(LOGNOTICE, "loading %s", GetSettingsFile().c_str());
if (!LoadSettings(GetSettingsFile()))
{
CLog::Log(LOGERROR, "Unable to load %s, creating new %s with default values", GetSettingsFile().c_str(), GetSettingsFile().c_str());
if (!Reset())
return false;
}
LoadSources();
LoadRSSFeeds();
LoadUserFolderLayout();
return true;
}
VECSOURCES *CSettings::GetSourcesFromType(const CStdString &type)
{
if (type == "programs" || type == "myprograms")
return &m_programSources;
else if (type == "files")
return &m_fileSources;
else if (type == "music")
return &m_musicSources;
else if (type == "video")
return &m_videoSources;
else if (type == "pictures")
return &m_pictureSources;
return NULL;
}
CStdString CSettings::GetDefaultSourceFromType(const CStdString &type)
{
CStdString defaultShare;
if (type == "programs" || type == "myprograms")
defaultShare = m_defaultProgramSource;
else if (type == "files")
defaultShare = m_defaultFileSource;
else if (type == "music")
defaultShare = m_defaultMusicSource;
else if (type == "pictures")
defaultShare = m_defaultPictureSource;
return defaultShare;
}
void CSettings::GetSources(const TiXmlElement* pRootElement, const CStdString& strTagName, VECSOURCES& items, CStdString& strDefault)
{
//CLog::Log(LOGDEBUG, " Parsing <%s> tag", strTagName.c_str());
strDefault = "";
items.clear();
const TiXmlNode *pChild = pRootElement->FirstChild(strTagName.c_str());
if (pChild)
{
pChild = pChild->FirstChild();
while (pChild > 0)
{
CStdString strValue = pChild->Value();
if (strValue == "source" || strValue == "bookmark") // "bookmark" left in for backwards compatibility
{
CMediaSource share;
if (GetSource(strTagName, pChild, share))
{
items.push_back(share);
}
else
{
CLog::Log(LOGERROR, " Missing or invalid <name> and/or <path> in source");
}
}
if (strValue == "default")
{
const TiXmlNode *pValueNode = pChild->FirstChild();
if (pValueNode)
{
const char* pszText = pChild->FirstChild()->Value();
if (strlen(pszText) > 0)
strDefault = pszText;
CLog::Log(LOGDEBUG, " Setting <default> source to : %s", strDefault.c_str());
}
}
pChild = pChild->NextSibling();
}
}
else
{
CLog::Log(LOGDEBUG, " <%s> tag is missing or sources.xml is malformed", strTagName.c_str());
}
}
bool CSettings::GetSource(const CStdString &category, const TiXmlNode *source, CMediaSource &share)
{
//CLog::Log(LOGDEBUG," ---- SOURCE START ----");
const TiXmlNode *pNodeName = source->FirstChild("name");
CStdString strName;
if (pNodeName && pNodeName->FirstChild())
{
strName = pNodeName->FirstChild()->Value();
//CLog::Log(LOGDEBUG," Found name: %s", strName.c_str());
}
// get multiple paths
vector<CStdString> vecPaths;
const TiXmlElement *pPathName = source->FirstChildElement("path");
while (pPathName)
{
if (pPathName->FirstChild())
{
CStdString strPath = pPathName->FirstChild()->Value();
// make sure there are no virtualpaths or stack paths defined in xboxmediacenter.xml
//CLog::Log(LOGDEBUG," Found path: %s", strPath.c_str());
if (!URIUtils::IsStack(strPath))
{
// translate special tags
if (!strPath.IsEmpty() && strPath.at(0) == '$')
{
CStdString strPathOld(strPath);
strPath = CUtil::TranslateSpecialSource(strPath);
if (!strPath.IsEmpty())
{
//CLog::Log(LOGDEBUG," -> Translated to path: %s", strPath.c_str());
}
else
{
//CLog::Log(LOGERROR," -> Skipping invalid token: %s", strPathOld.c_str());
pPathName = pPathName->NextSiblingElement("path");
continue;
}
}
URIUtils::AddSlashAtEnd(strPath);
vecPaths.push_back(strPath);
}
else
CLog::Log(LOGERROR," Invalid path type (%s) in source", strPath.c_str());
}
pPathName = pPathName->NextSiblingElement("path");
}
const TiXmlNode *pLockMode = source->FirstChild("lockmode");
const TiXmlNode *pLockCode = source->FirstChild("lockcode");
const TiXmlNode *pBadPwdCount = source->FirstChild("badpwdcount");
const TiXmlNode *pThumbnailNode = source->FirstChild("thumbnail");
if (!strName.IsEmpty() && vecPaths.size() > 0)
{
vector<CStdString> verifiedPaths;
// disallowed for files, or theres only a single path in the vector
if ((category.Equals("files")) || (vecPaths.size() == 1))
verifiedPaths.push_back(vecPaths[0]);
// multiple paths?
else
{
// validate the paths
for (int j = 0; j < (int)vecPaths.size(); ++j)
{
CURL url(vecPaths[j]);
CStdString protocol = url.GetProtocol();
bool bIsInvalid = false;
// for my programs
if (category.Equals("programs") || category.Equals("myprograms"))
{
// only allow HD and plugins
if (url.IsLocal() || protocol.Equals("plugin"))
verifiedPaths.push_back(vecPaths[j]);
else
bIsInvalid = true;
}
// for others allow everything (if the user does something silly, we can't stop them)
else
verifiedPaths.push_back(vecPaths[j]);
// error message
if (bIsInvalid)
CLog::Log(LOGERROR," Invalid path type (%s) for multipath source", vecPaths[j].c_str());
}
// no valid paths? skip to next source
if (verifiedPaths.size() == 0)
{
CLog::Log(LOGERROR," Missing or invalid <name> and/or <path> in source");
return false;
}
}
share.FromNameAndPaths(category, strName, verifiedPaths);
share.m_iBadPwdCount = 0;
if (pLockMode)
{
share.m_iLockMode = LockType(atoi(pLockMode->FirstChild()->Value()));
share.m_iHasLock = 2;
}
if (pLockCode)
{
if (pLockCode->FirstChild())
share.m_strLockCode = pLockCode->FirstChild()->Value();
}
if (pBadPwdCount)
{
if (pBadPwdCount->FirstChild())
share.m_iBadPwdCount = atoi( pBadPwdCount->FirstChild()->Value() );
}
if (pThumbnailNode)
{
if (pThumbnailNode->FirstChild())
share.m_strThumbnailImage = pThumbnailNode->FirstChild()->Value();
}
return true;
}
return false;
}
bool CSettings::GetPath(const TiXmlElement* pRootElement, const char *tagName, CStdString &strValue)
{
CStdString strDefault = strValue;
if (XMLUtils::GetPath(pRootElement, tagName, strValue))
{ // tag exists
// check for "-" for backward compatibility
if (!strValue.Equals("-"))
return true;
}
// tag doesn't exist - set default
strValue = strDefault;
return false;
}
bool CSettings::GetString(const TiXmlElement* pRootElement, const char *tagName, CStdString &strValue, const CStdString& strDefaultValue)
{
if (XMLUtils::GetString(pRootElement, tagName, strValue))
{ // tag exists
// check for "-" for backward compatibility
if (!strValue.Equals("-"))
return true;
}
// tag doesn't exist - set default
strValue = strDefaultValue;
return false;
}
bool CSettings::GetString(const TiXmlElement* pRootElement, const char *tagName, char *szValue, const CStdString& strDefaultValue)
{
CStdString strValue;
bool ret = GetString(pRootElement, tagName, strValue, strDefaultValue);
if (szValue)
strcpy(szValue, strValue.c_str());
return ret;
}
bool CSettings::GetInteger(const TiXmlElement* pRootElement, const char *tagName, int& iValue, const int iDefault, const int iMin, const int iMax)
{
if (XMLUtils::GetInt(pRootElement, tagName, iValue, iMin, iMax))
return true;
// default
iValue = iDefault;
return false;
}
bool CSettings::GetFloat(const TiXmlElement* pRootElement, const char *tagName, float& fValue, const float fDefault, const float fMin, const float fMax)
{
if (XMLUtils::GetFloat(pRootElement, tagName, fValue, fMin, fMax))
return true;
// default
fValue = fDefault;
return false;
}
void CSettings::GetViewState(const TiXmlElement *pRootElement, const CStdString &strTagName, CViewState &viewState, SORT_METHOD defaultSort, int defaultView)
{
const TiXmlElement* pNode = pRootElement->FirstChildElement(strTagName);
if (!pNode)
{
viewState.m_sortMethod = defaultSort;
viewState.m_viewMode = defaultView;
return;
}
GetInteger(pNode, "viewmode", viewState.m_viewMode, defaultView, DEFAULT_VIEW_LIST, DEFAULT_VIEW_MAX);
int sortMethod;
GetInteger(pNode, "sortmethod", sortMethod, defaultSort, SORT_METHOD_NONE, SORT_METHOD_MAX);
viewState.m_sortMethod = (SORT_METHOD)sortMethod;
int sortOrder;
GetInteger(pNode, "sortorder", sortOrder, SortOrderAscending, SortOrderNone, SortOrderDescending);
viewState.m_sortOrder = (SortOrder)sortOrder;
}
void CSettings::SetViewState(TiXmlNode *pRootNode, const CStdString &strTagName, const CViewState &viewState) const
{
TiXmlElement newElement(strTagName);
TiXmlNode *pNewNode = pRootNode->InsertEndChild(newElement);
if (pNewNode)
{
XMLUtils::SetInt(pNewNode, "viewmode", viewState.m_viewMode);
XMLUtils::SetInt(pNewNode, "sortmethod", (int)viewState.m_sortMethod);
XMLUtils::SetInt(pNewNode, "sortorder", (int)viewState.m_sortOrder);
}
}
bool CSettings::LoadCalibration(const TiXmlElement* pRoot, const CStdString& strSettingsFile)
{
const TiXmlElement *pElement = pRoot->FirstChildElement("resolutions");
if (!pElement)
{
CLog::Log(LOGERROR, "%s Doesn't contain <resolutions>", strSettingsFile.c_str());
return false;
}
const TiXmlElement *pResolution = pElement->FirstChildElement("resolution");
while (pResolution)
{
// get the data for this resolution
CStdString mode;
XMLUtils::GetString(pResolution, "description", mode);
// find this resolution in our resolution vector
for (unsigned int res = 0; res < m_ResInfo.size(); res++)
{
if (res == RES_WINDOW)
continue;
if (m_ResInfo[res].strMode == mode)
{ // found, read in the rest of the information for this item
const TiXmlElement *pOverscan = pResolution->FirstChildElement("overscan");
if (pOverscan)
{
GetInteger(pOverscan, "left", m_ResInfo[res].Overscan.left, 0, -m_ResInfo[res].iWidth / 4, m_ResInfo[res].iWidth / 4);
GetInteger(pOverscan, "top", m_ResInfo[res].Overscan.top, 0, -m_ResInfo[res].iHeight / 4, m_ResInfo[res].iHeight / 4);
GetInteger(pOverscan, "right", m_ResInfo[res].Overscan.right, m_ResInfo[res].iWidth, m_ResInfo[res].iWidth / 2, m_ResInfo[res].iWidth*3 / 2);
GetInteger(pOverscan, "bottom", m_ResInfo[res].Overscan.bottom, m_ResInfo[res].iHeight, m_ResInfo[res].iHeight / 2, m_ResInfo[res].iHeight*3 / 2);
}
// get the appropriate "safe graphics area" = 10% for 4x3, 3.5% for 16x9
float fSafe;
if (res == RES_PAL_4x3 || res == RES_NTSC_4x3 || res == RES_PAL60_4x3 || res == RES_HDTV_480p_4x3)
fSafe = 0.1f;
else
fSafe = 0.035f;
GetInteger(pResolution, "subtitles", m_ResInfo[res].iSubtitles, (int)((1 - fSafe)*m_ResInfo[res].iHeight), m_ResInfo[res].iHeight / 2, m_ResInfo[res].iHeight*5 / 4);
GetFloat(pResolution, "pixelratio", m_ResInfo[res].fPixelRatio, 128.0f / 117.0f, 0.5f, 2.0f);
/* CLog::Log(LOGDEBUG, " calibration for %s %ix%i", m_ResInfo[res].strMode, m_ResInfo[res].iWidth, m_ResInfo[res].iHeight);
CLog::Log(LOGDEBUG, " subtitle yposition:%i pixelratio:%03.3f offsets:(%i,%i)->(%i,%i)",
m_ResInfo[res].iSubtitles, m_ResInfo[res].fPixelRatio,
m_ResInfo[res].Overscan.left, m_ResInfo[res].Overscan.top,
m_ResInfo[res].Overscan.right, m_ResInfo[res].Overscan.bottom);*/
}
}
// iterate around
pResolution = pResolution->NextSiblingElement("resolution");
/* Hmm, these stuff shouldn't be releaded, they should be used instead of our internal
id counter to select what resolution is affected by this settings
#ifdef HAS_XRANDR
const CStdString def("");
CStdString val;
GetString(pResolution, "xrandrid", val, def);
strncpy(m_ResInfo[iRes].strId, val.c_str(), sizeof(m_ResInfo[iRes].strId));
GetString(pResolution, "output", val, def);
strncpy(m_ResInfo[iRes].strOutput, val.c_str(), sizeof(m_ResInfo[iRes].strOutput));
GetFloat(pResolution, "refreshrate", m_ResInfo[iRes].fRefreshRate, 0, 0, 200);
#endif
*/
}
return true;
}
bool CSettings::SaveCalibration(TiXmlNode* pRootNode) const
{
TiXmlElement xmlRootElement("resolutions");
TiXmlNode *pRoot = pRootNode->InsertEndChild(xmlRootElement);
// save WINDOW, DESKTOP and CUSTOM resolution
for (size_t i = RES_WINDOW ; i < m_ResInfo.size() ; i++)
{
// Write the resolution tag
TiXmlElement resElement("resolution");
TiXmlNode *pNode = pRoot->InsertEndChild(resElement);
// Now write each of the pieces of information we need...
XMLUtils::SetString(pNode, "description", m_ResInfo[i].strMode);
XMLUtils::SetInt(pNode, "subtitles", m_ResInfo[i].iSubtitles);
XMLUtils::SetFloat(pNode, "pixelratio", m_ResInfo[i].fPixelRatio);
#ifdef HAS_XRANDR
XMLUtils::SetFloat(pNode, "refreshrate", m_ResInfo[i].fRefreshRate);
XMLUtils::SetString(pNode, "output", m_ResInfo[i].strOutput);
XMLUtils::SetString(pNode, "xrandrid", m_ResInfo[i].strId);
#endif
// create the overscan child
TiXmlElement overscanElement("overscan");
TiXmlNode *pOverscanNode = pNode->InsertEndChild(overscanElement);
XMLUtils::SetInt(pOverscanNode, "left", m_ResInfo[i].Overscan.left);
XMLUtils::SetInt(pOverscanNode, "top", m_ResInfo[i].Overscan.top);
XMLUtils::SetInt(pOverscanNode, "right", m_ResInfo[i].Overscan.right);
XMLUtils::SetInt(pOverscanNode, "bottom", m_ResInfo[i].Overscan.bottom);
}
return true;
}
bool CSettings::LoadSettings(const CStdString& strSettingsFile)
{
// load the xml file
CXBMCTinyXML xmlDoc;
if (!xmlDoc.LoadFile(strSettingsFile))
{
CLog::Log(LOGERROR, "%s, Line %d\n%s", strSettingsFile.c_str(), xmlDoc.ErrorRow(), xmlDoc.ErrorDesc());
return false;
}
TiXmlElement *pRootElement = xmlDoc.RootElement();
if (strcmpi(pRootElement->Value(), "settings") != 0)
{
CLog::Log(LOGERROR, "%s\nDoesn't contain <settings>", strSettingsFile.c_str());
return false;
}
// mymusic settings
TiXmlElement *pElement = pRootElement->FirstChildElement("mymusic");
if (pElement)
{
TiXmlElement *pChild = pElement->FirstChildElement("playlist");
if (pChild)
{
XMLUtils::GetBoolean(pChild, "repeat", m_bMyMusicPlaylistRepeat);
XMLUtils::GetBoolean(pChild, "shuffle", m_bMyMusicPlaylistShuffle);
}
// if the user happened to reboot in the middle of the scan we save this state
pChild = pElement->FirstChildElement("scanning");
if (pChild)
{
XMLUtils::GetBoolean(pChild, "isscanning", m_bMyMusicIsScanning);
}
GetInteger(pElement, "startwindow", m_iMyMusicStartWindow, WINDOW_MUSIC_FILES, WINDOW_MUSIC_FILES, WINDOW_MUSIC_NAV); //501; view songs
XMLUtils::GetBoolean(pElement, "songinfoinvis", m_bMyMusicSongInfoInVis);
XMLUtils::GetBoolean(pElement, "songthumbinvis", m_bMyMusicSongThumbInVis);
GetPath(pElement, "defaultlibview", m_defaultMusicLibSource);
}
// myvideos settings
pElement = pRootElement->FirstChildElement("myvideos");
if (pElement)
{
GetInteger(pElement, "startwindow", m_iVideoStartWindow, WINDOW_VIDEO_FILES, WINDOW_VIDEO_FILES, WINDOW_VIDEO_NAV);
XMLUtils::GetBoolean(pElement, "stackvideos", m_videoStacking);
// Read the watchmode settings for the various media views
GetInteger(pElement, "watchmodemovies", m_watchMode["movies"], VIDEO_SHOW_ALL, VIDEO_SHOW_ALL, VIDEO_SHOW_WATCHED);
GetInteger(pElement, "watchmodetvshows", m_watchMode["tvshows"], VIDEO_SHOW_ALL, VIDEO_SHOW_ALL, VIDEO_SHOW_WATCHED);
GetInteger(pElement, "watchmodemusicvideos", m_watchMode["musicvideos"], VIDEO_SHOW_ALL, VIDEO_SHOW_ALL, VIDEO_SHOW_WATCHED);
XMLUtils::GetBoolean(pElement, "flatten", m_bMyVideoNavFlatten);
TiXmlElement *pChild = pElement->FirstChildElement("playlist");
if (pChild)
{ // playlist
XMLUtils::GetBoolean(pChild, "repeat", m_bMyVideoPlaylistRepeat);
XMLUtils::GetBoolean(pChild, "shuffle", m_bMyVideoPlaylistShuffle);
}
}
pElement = pRootElement->FirstChildElement("viewstates");
if (pElement)
{
GetViewState(pElement, "musicnavartists", m_viewStateMusicNavArtists);
GetViewState(pElement, "musicnavalbums", m_viewStateMusicNavAlbums);
GetViewState(pElement, "musicnavsongs", m_viewStateMusicNavSongs);
GetViewState(pElement, "musiclastfm", m_viewStateMusicLastFM);
GetViewState(pElement, "videonavactors", m_viewStateVideoNavActors);
GetViewState(pElement, "videonavyears", m_viewStateVideoNavYears);
GetViewState(pElement, "videonavgenres", m_viewStateVideoNavGenres);
GetViewState(pElement, "videonavtitles", m_viewStateVideoNavTitles);
GetViewState(pElement, "videonavepisodes", m_viewStateVideoNavEpisodes, SORT_METHOD_EPISODE);
GetViewState(pElement, "videonavtvshows", m_viewStateVideoNavTvShows);
GetViewState(pElement, "videonavseasons", m_viewStateVideoNavSeasons);
GetViewState(pElement, "videonavmusicvideos", m_viewStateVideoNavMusicVideos);
GetViewState(pElement, "programs", m_viewStatePrograms, SORT_METHOD_LABEL, DEFAULT_VIEW_AUTO);
GetViewState(pElement, "pictures", m_viewStatePictures, SORT_METHOD_LABEL, DEFAULT_VIEW_AUTO);
GetViewState(pElement, "videofiles", m_viewStateVideoFiles, SORT_METHOD_LABEL, DEFAULT_VIEW_AUTO);
GetViewState(pElement, "musicfiles", m_viewStateMusicFiles, SORT_METHOD_LABEL, DEFAULT_VIEW_AUTO);
}
// general settings
pElement = pRootElement->FirstChildElement("general");
if (pElement)
{
GetInteger(pElement, "systemtotaluptime", m_iSystemTimeTotalUp, 0, 0, INT_MAX);
GetInteger(pElement, "httpapibroadcastlevel", m_HttpApiBroadcastLevel, 0, 0, 255);
GetInteger(pElement, "httpapibroadcastport", m_HttpApiBroadcastPort, 8278, 1, 65535);
XMLUtils::GetBoolean(pElement, "addonautoupdate", m_bAddonAutoUpdate);
XMLUtils::GetBoolean(pElement, "addonnotifications", m_bAddonNotifications);
XMLUtils::GetBoolean(pElement, "addonforeignfilter", m_bAddonForeignFilter);
}
pElement = pRootElement->FirstChildElement("defaultvideosettings");
if (pElement)
{
int deinterlaceMode;
bool deinterlaceModePresent = GetInteger(pElement, "deinterlacemode", deinterlaceMode, VS_DEINTERLACEMODE_OFF, VS_DEINTERLACEMODE_OFF, VS_DEINTERLACEMODE_FORCE);
int interlaceMethod;
bool interlaceMethodPresent = GetInteger(pElement, "interlacemethod", interlaceMethod, VS_INTERLACEMETHOD_AUTO, VS_INTERLACEMETHOD_AUTO, VS_INTERLACEMETHOD_MAX);
// For smooth conversion of settings stored before the deinterlaceMode existed
if (!deinterlaceModePresent && interlaceMethodPresent)
{
if (interlaceMethod == VS_INTERLACEMETHOD_NONE)
{
deinterlaceMode = VS_DEINTERLACEMODE_OFF;
interlaceMethod = VS_INTERLACEMETHOD_AUTO;
}
else if (interlaceMethod == VS_INTERLACEMETHOD_AUTO)
{
deinterlaceMode = VS_DEINTERLACEMODE_AUTO;
}
else
{
deinterlaceMode = VS_DEINTERLACEMODE_FORCE;
}
}
m_defaultVideoSettings.m_DeinterlaceMode = (EDEINTERLACEMODE)deinterlaceMode;
m_defaultVideoSettings.m_InterlaceMethod = (EINTERLACEMETHOD)interlaceMethod;
int scalingMethod;
GetInteger(pElement, "scalingmethod", scalingMethod, VS_SCALINGMETHOD_LINEAR, VS_SCALINGMETHOD_NEAREST, VS_SCALINGMETHOD_MAX);
m_defaultVideoSettings.m_ScalingMethod = (ESCALINGMETHOD)scalingMethod;
GetInteger(pElement, "viewmode", m_defaultVideoSettings.m_ViewMode, VIEW_MODE_NORMAL, VIEW_MODE_NORMAL, VIEW_MODE_CUSTOM);
GetFloat(pElement, "zoomamount", m_defaultVideoSettings.m_CustomZoomAmount, 1.0f, 0.5f, 2.0f);
GetFloat(pElement, "pixelratio", m_defaultVideoSettings.m_CustomPixelRatio, 1.0f, 0.5f, 2.0f);
GetFloat(pElement, "verticalshift", m_defaultVideoSettings.m_CustomVerticalShift, 0.0f, -2.0f, 2.0f);
GetFloat(pElement, "volumeamplification", m_defaultVideoSettings.m_VolumeAmplification, VOLUME_DRC_MINIMUM * 0.01f, VOLUME_DRC_MINIMUM * 0.01f, VOLUME_DRC_MAXIMUM * 0.01f);
GetFloat(pElement, "noisereduction", m_defaultVideoSettings.m_NoiseReduction, 0.0f, 0.0f, 1.0f);
XMLUtils::GetBoolean(pElement, "postprocess", m_defaultVideoSettings.m_PostProcess);
GetFloat(pElement, "sharpness", m_defaultVideoSettings.m_Sharpness, 0.0f, -1.0f, 1.0f);
XMLUtils::GetBoolean(pElement, "outputtoallspeakers", m_defaultVideoSettings.m_OutputToAllSpeakers);
XMLUtils::GetBoolean(pElement, "showsubtitles", m_defaultVideoSettings.m_SubtitleOn);
GetFloat(pElement, "brightness", m_defaultVideoSettings.m_Brightness, 50, 0, 100);
GetFloat(pElement, "contrast", m_defaultVideoSettings.m_Contrast, 50, 0, 100);
GetFloat(pElement, "gamma", m_defaultVideoSettings.m_Gamma, 20, 0, 100);
GetFloat(pElement, "audiodelay", m_defaultVideoSettings.m_AudioDelay, 0.0f, -10.0f, 10.0f);
GetFloat(pElement, "subtitledelay", m_defaultVideoSettings.m_SubtitleDelay, 0.0f, -10.0f, 10.0f);
XMLUtils::GetBoolean(pElement, "autocrop", m_defaultVideoSettings.m_Crop);
XMLUtils::GetBoolean(pElement, "nonlinstretch", m_defaultVideoSettings.m_CustomNonLinStretch);
m_defaultVideoSettings.m_SubtitleCached = false;
}
// audio settings
pElement = pRootElement->FirstChildElement("audio");
if (pElement)
{
XMLUtils::GetBoolean(pElement, "mute", m_bMute);
GetFloat(pElement, "fvolumelevel", m_fVolumeLevel, VOLUME_MAXIMUM, VOLUME_MINIMUM, VOLUME_MAXIMUM);
}
LoadCalibration(pRootElement, strSettingsFile);
g_guiSettings.LoadXML(pRootElement);
LoadSkinSettings(pRootElement);
// Configure the PlayerCoreFactory
LoadPlayerCoreFactorySettings("special://xbmc/system/playercorefactory.xml", true);
LoadPlayerCoreFactorySettings(GetUserDataItem("playercorefactory.xml"), false);
// Advanced settings
g_advancedSettings.Load();
// Add the list of disc stub extensions (if any) to the list of video extensions
if (!m_discStubExtensions.IsEmpty())
g_settings.m_videoExtensions += "|" + m_discStubExtensions;
// Default players?
CLog::Log(LOGNOTICE, "Default DVD Player: %s", g_advancedSettings.m_videoDefaultDVDPlayer.c_str());
CLog::Log(LOGNOTICE, "Default Video Player: %s", g_advancedSettings.m_videoDefaultPlayer.c_str());
CLog::Log(LOGNOTICE, "Default Audio Player: %s", g_advancedSettings.m_audioDefaultPlayer.c_str());
// setup any logging...
if (g_guiSettings.GetBool("debug.showloginfo"))
{
g_advancedSettings.m_logLevel = std::max(g_advancedSettings.m_logLevelHint, LOG_LEVEL_DEBUG_FREEMEM);
CLog::Log(LOGNOTICE, "Enabled debug logging due to GUI setting (%d)", g_advancedSettings.m_logLevel);
}
else
{
g_advancedSettings.m_logLevel = std::min(g_advancedSettings.m_logLevelHint, LOG_LEVEL_DEBUG/*LOG_LEVEL_NORMAL*/);
CLog::Log(LOGNOTICE, "Disabled debug logging due to GUI setting. Level %d.", g_advancedSettings.m_logLevel);
}
CLog::SetLogLevel(g_advancedSettings.m_logLevel);
return true;
}
bool CSettings::LoadPlayerCoreFactorySettings(const CStdString& fileStr, bool clear)
{
CLog::Log(LOGNOTICE, "Loading player core factory settings from %s.", fileStr.c_str());
if (!CFile::Exists(fileStr))
{ // tell the user it doesn't exist
CLog::Log(LOGNOTICE, "%s does not exist. Skipping.", fileStr.c_str());
return false;
}
CXBMCTinyXML playerCoreFactoryXML;
if (!playerCoreFactoryXML.LoadFile(fileStr))
{
CLog::Log(LOGERROR, "Error loading %s, Line %d (%s)", fileStr.c_str(), playerCoreFactoryXML.ErrorRow(), playerCoreFactoryXML.ErrorDesc());
return false;
}
return CPlayerCoreFactory::LoadConfiguration(playerCoreFactoryXML.RootElement(), clear);
}
bool CSettings::SaveSettings(const CStdString& strSettingsFile, CGUISettings *localSettings /* = NULL */) const
{
CXBMCTinyXML xmlDoc;
TiXmlElement xmlRootElement("settings");
TiXmlNode *pRoot = xmlDoc.InsertEndChild(xmlRootElement);
if (!pRoot) return false;
// write our tags one by one - just a big list for now (can be flashed up later)
// mymusic settings
TiXmlElement musicNode("mymusic");
TiXmlNode *pNode = pRoot->InsertEndChild(musicNode);
if (!pNode) return false;
{
TiXmlElement childNode("playlist");
TiXmlNode *pChild = pNode->InsertEndChild(childNode);
if (!pChild) return false;
XMLUtils::SetBoolean(pChild, "repeat", m_bMyMusicPlaylistRepeat);
XMLUtils::SetBoolean(pChild, "shuffle", m_bMyMusicPlaylistShuffle);
}
{
TiXmlElement childNode("scanning");
TiXmlNode *pChild = pNode->InsertEndChild(childNode);
if (!pChild) return false;
XMLUtils::SetBoolean(pChild, "isscanning", m_bMyMusicIsScanning);
}
XMLUtils::SetInt(pNode, "startwindow", m_iMyMusicStartWindow);
XMLUtils::SetBoolean(pNode, "songinfoinvis", m_bMyMusicSongInfoInVis);
XMLUtils::SetBoolean(pNode, "songthumbinvis", m_bMyMusicSongThumbInVis);
XMLUtils::SetPath(pNode, "defaultlibview", m_defaultMusicLibSource);
// myvideos settings
TiXmlElement videosNode("myvideos");
pNode = pRoot->InsertEndChild(videosNode);
if (!pNode) return false;
XMLUtils::SetInt(pNode, "startwindow", m_iVideoStartWindow);
XMLUtils::SetBoolean(pNode, "stackvideos", m_videoStacking);
XMLUtils::SetInt(pNode, "watchmodemovies", m_watchMode.find("movies")->second);
XMLUtils::SetInt(pNode, "watchmodetvshows", m_watchMode.find("tvshows")->second);
XMLUtils::SetInt(pNode, "watchmodemusicvideos", m_watchMode.find("musicvideos")->second);
XMLUtils::SetBoolean(pNode, "flatten", m_bMyVideoNavFlatten);
{ // playlist window
TiXmlElement childNode("playlist");
TiXmlNode *pChild = pNode->InsertEndChild(childNode);
if (!pChild) return false;
XMLUtils::SetBoolean(pChild, "repeat", m_bMyVideoPlaylistRepeat);
XMLUtils::SetBoolean(pChild, "shuffle", m_bMyVideoPlaylistShuffle);
}
// view states
TiXmlElement viewStateNode("viewstates");
pNode = pRoot->InsertEndChild(viewStateNode);
if (pNode)
{
SetViewState(pNode, "musicnavartists", m_viewStateMusicNavArtists);
SetViewState(pNode, "musicnavalbums", m_viewStateMusicNavAlbums);
SetViewState(pNode, "musicnavsongs", m_viewStateMusicNavSongs);
SetViewState(pNode, "musiclastfm", m_viewStateMusicLastFM);
SetViewState(pNode, "videonavactors", m_viewStateVideoNavActors);
SetViewState(pNode, "videonavyears", m_viewStateVideoNavYears);
SetViewState(pNode, "videonavgenres", m_viewStateVideoNavGenres);
SetViewState(pNode, "videonavtitles", m_viewStateVideoNavTitles);
SetViewState(pNode, "videonavepisodes", m_viewStateVideoNavEpisodes);
SetViewState(pNode, "videonavseasons", m_viewStateVideoNavSeasons);
SetViewState(pNode, "videonavtvshows", m_viewStateVideoNavTvShows);
SetViewState(pNode, "videonavmusicvideos", m_viewStateVideoNavMusicVideos);
SetViewState(pNode, "programs", m_viewStatePrograms);
SetViewState(pNode, "pictures", m_viewStatePictures);
SetViewState(pNode, "videofiles", m_viewStateVideoFiles);
SetViewState(pNode, "musicfiles", m_viewStateMusicFiles);
}
// general settings
TiXmlElement generalNode("general");
pNode = pRoot->InsertEndChild(generalNode);
if (!pNode) return false;
XMLUtils::SetInt(pNode, "systemtotaluptime", m_iSystemTimeTotalUp);
XMLUtils::SetInt(pNode, "httpapibroadcastport", m_HttpApiBroadcastPort);
XMLUtils::SetInt(pNode, "httpapibroadcastlevel", m_HttpApiBroadcastLevel);
XMLUtils::SetBoolean(pNode, "addonautoupdate", m_bAddonAutoUpdate);
XMLUtils::SetBoolean(pNode, "addonnotifications", m_bAddonNotifications);
XMLUtils::SetBoolean(pNode, "addonforeignfilter", m_bAddonForeignFilter);
// default video settings
TiXmlElement videoSettingsNode("defaultvideosettings");
pNode = pRoot->InsertEndChild(videoSettingsNode);
if (!pNode) return false;
XMLUtils::SetInt(pNode, "deinterlacemode", m_defaultVideoSettings.m_DeinterlaceMode);
XMLUtils::SetInt(pNode, "interlacemethod", m_defaultVideoSettings.m_InterlaceMethod);
XMLUtils::SetInt(pNode, "scalingmethod", m_defaultVideoSettings.m_ScalingMethod);
XMLUtils::SetFloat(pNode, "noisereduction", m_defaultVideoSettings.m_NoiseReduction);
XMLUtils::SetBoolean(pNode, "postprocess", m_defaultVideoSettings.m_PostProcess);
XMLUtils::SetFloat(pNode, "sharpness", m_defaultVideoSettings.m_Sharpness);
XMLUtils::SetInt(pNode, "viewmode", m_defaultVideoSettings.m_ViewMode);
XMLUtils::SetFloat(pNode, "zoomamount", m_defaultVideoSettings.m_CustomZoomAmount);
XMLUtils::SetFloat(pNode, "pixelratio", m_defaultVideoSettings.m_CustomPixelRatio);
XMLUtils::SetFloat(pNode, "verticalshift", m_defaultVideoSettings.m_CustomVerticalShift);
XMLUtils::SetFloat(pNode, "volumeamplification", m_defaultVideoSettings.m_VolumeAmplification);
XMLUtils::SetBoolean(pNode, "outputtoallspeakers", m_defaultVideoSettings.m_OutputToAllSpeakers);
XMLUtils::SetBoolean(pNode, "showsubtitles", m_defaultVideoSettings.m_SubtitleOn);
XMLUtils::SetFloat(pNode, "brightness", m_defaultVideoSettings.m_Brightness);
XMLUtils::SetFloat(pNode, "contrast", m_defaultVideoSettings.m_Contrast);
XMLUtils::SetFloat(pNode, "gamma", m_defaultVideoSettings.m_Gamma);
XMLUtils::SetFloat(pNode, "audiodelay", m_defaultVideoSettings.m_AudioDelay);
XMLUtils::SetFloat(pNode, "subtitledelay", m_defaultVideoSettings.m_SubtitleDelay);
XMLUtils::SetBoolean(pNode, "autocrop", m_defaultVideoSettings.m_Crop);
XMLUtils::SetBoolean(pNode, "nonlinstretch", m_defaultVideoSettings.m_CustomNonLinStretch);
// audio settings
TiXmlElement volumeNode("audio");
pNode = pRoot->InsertEndChild(volumeNode);
if (!pNode) return false;
XMLUtils::SetBoolean(pNode, "mute", m_bMute);
XMLUtils::SetFloat(pNode, "fvolumelevel", m_fVolumeLevel);
SaveCalibration(pRoot);
if (localSettings) // local settings to save
localSettings->SaveXML(pRoot);
else // save the global settings
g_guiSettings.SaveXML(pRoot);
SaveSkinSettings(pRoot);
// For mastercode
SaveProfiles( PROFILES_FILE );
// save the file
return xmlDoc.SaveFile(strSettingsFile);
}
bool CSettings::LoadProfile(unsigned int index)
{
unsigned int oldProfile = m_currentProfile;
m_currentProfile = index;
CStdString strOldSkin = g_guiSettings.GetString("lookandfeel.skin");
CStdString strOldFont = g_guiSettings.GetString("lookandfeel.font");
CStdString strOldTheme = g_guiSettings.GetString("lookandfeel.skintheme");
CStdString strOldColors = g_guiSettings.GetString("lookandfeel.skincolors");
if (Load())
{
CreateProfileFolders();
// initialize our charset converter
g_charsetConverter.reset();
// Load the langinfo to have user charset <-> utf-8 conversion
CStdString strLanguage = g_guiSettings.GetString("locale.language");
strLanguage[0] = toupper(strLanguage[0]);
CStdString strLangInfoPath;
strLangInfoPath.Format("special://xbmc/language/%s/langinfo.xml", strLanguage.c_str());
CLog::Log(LOGINFO, "load language info file:%s", strLangInfoPath.c_str());
g_langInfo.Load(strLangInfoPath);
CButtonTranslator::GetInstance().Load(true);
g_localizeStrings.Load("special://xbmc/language/", strLanguage);
g_Mouse.SetEnabled(g_guiSettings.GetBool("input.enablemouse"));
g_infoManager.ResetCache();
g_infoManager.ResetLibraryBools();
// always reload the skin - we need it for the new language strings
g_application.ReloadSkin();
if (m_currentProfile != 0)
{
CXBMCTinyXML doc;
if (doc.LoadFile(URIUtils::AddFileToFolder(GetUserDataFolder(),"guisettings.xml")))
g_guiSettings.LoadMasterLock(doc.RootElement());
}
CPasswordManager::GetInstance().Clear();
// to set labels - shares are reloaded
#if !defined(_WIN32) && defined(HAS_DVD_DRIVE)
MEDIA_DETECT::CDetectDVDMedia::UpdateState();
#endif
// init windows
CGUIMessage msg(GUI_MSG_NOTIFY_ALL,0,0,GUI_MSG_WINDOW_RESET);
g_windowManager.SendMessage(msg);
CUtil::DeleteDirectoryCache();
g_directoryCache.Clear();
return true;
}
m_currentProfile = oldProfile;
return false;
}
bool CSettings::DeleteProfile(unsigned int index)
{
const CProfile *profile = GetProfile(index);
if (!profile)
return false;
CGUIDialogYesNo* dlgYesNo = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
if (dlgYesNo)
{
CStdString message;
CStdString str = g_localizeStrings.Get(13201);
message.Format(str.c_str(), profile->getName());
dlgYesNo->SetHeading(13200);
dlgYesNo->SetLine(0, message);
dlgYesNo->SetLine(1, "");
dlgYesNo->SetLine(2, "");
dlgYesNo->DoModal();