~x3lectric/xbmc/svn-trunk

« back to all changes in this revision

Viewing changes to xbmc/Settings.cpp

  • Committer: tslayer
  • Date: 2004-08-05 23:57:52 UTC
  • Revision ID: svn-v4:568bbfeb-2a22-0410-94d2-cc84cf5bfa90:trunk/XBMC:1846
  - fixed: Fallback skin is now Project Mayhem and not MediaCenter

  - fixed: Only use directory name as description for default.xbe

  - added: Different Log Levels can now be specified.  Default is NOTICE.

         . Please note that the default loglevel is NOTICE.
         . The LogLevels that can be used are defined in utils/log.h
         . I've changed some of the Log statements to use the loglevel
           as I saw fit, but please change if you feel it should be another
           log level.

Show diffs side-by-side

added added

removed removed

Lines of Context:
352
352
        strcpy(g_stSettings.m_strRipPath, "");
353
353
 
354
354
        g_stSettings.m_nVolumeLevel = 0;
 
355
        g_stSettings.m_iLogLevel = LOGNOTICE;
355
356
}
356
357
 
357
358
CSettings::~CSettings(void)
370
371
  }
371
372
        if (!SaveSettings("T:\\settings.xml", true))
372
373
        {
373
 
                CLog::Log("Unable to save settings to T:\\settings.xml");
 
374
                CLog::Log(LOGERROR, "Unable to save settings to T:\\settings.xml");
374
375
        }
375
376
}
376
377
 
378
379
{
379
380
        // load settings file...
380
381
        bXboxMediacenter=bSettings=false;
381
 
        CLog::Log("loading T:\\settings.xml");
 
382
        CLog::Log(LOGNOTICE, "loading T:\\settings.xml");
382
383
        if (!LoadSettings("T:\\settings.xml", true))
383
384
        {
384
 
                CLog::Log("Unable to load T:\\settings.xml, creating new T:\\settings.xml with default values");
 
385
                CLog::Log(LOGERROR, "Unable to load T:\\settings.xml, creating new T:\\settings.xml with default values");
385
386
                Save();
386
387
                if (!(bSettings=LoadSettings("T:\\settings.xml", true)))
387
388
                        return false;
388
389
        }
389
390
 
390
391
        // load xml file...
391
 
        CLog::Log("loading Q:\\XboxMediaCenter.xml");
 
392
        CLog::Log(LOGNOTICE, "loading Q:\\XboxMediaCenter.xml");
392
393
        CStdString strXMLFile = "Q:\\XboxMediaCenter.xml";
393
394
        TiXmlDocument xmlDoc;
394
395
        if ( !xmlDoc.LoadFile( strXMLFile.c_str() ) ) 
405
406
                return false;
406
407
        }
407
408
 
 
409
        GetInteger(pRootElement, "loglevel", g_stSettings.m_iLogLevel, LOGWARNING, LOGDEBUG, LOGNONE);
 
410
 
408
411
        TiXmlElement* pFileTypeIcons =pRootElement->FirstChildElement("filetypeicons");
409
412
        TiXmlNode* pFileType=pFileTypeIcons->FirstChild();
410
413
        while (pFileType)
598
601
 
599
602
void CSettings::GetShares(const TiXmlElement* pRootElement, const CStdString& strTagName, VECSHARES& items,CStdString& strDefault)
600
603
{
601
 
        CLog::Log("  Parsing <%s> tag", strTagName.c_str());
 
604
        CLog::Log(LOGDEBUG, "  Parsing <%s> tag", strTagName.c_str());
602
605
        strDefault="";
603
606
        const TiXmlNode *pChild = pRootElement->FirstChild(strTagName.c_str());
604
607
        if (pChild)
616
619
                                if (pNodeName && pPathName)
617
620
                                {
618
621
                                        const char* szName=pNodeName->FirstChild()->Value();
619
 
                                        CLog::Log("    Share Name: %s", szName);
 
622
                                        CLog::Log(LOGDEBUG, "    Share Name: %s", szName);
620
623
                                        const char* szPath=pPathName->FirstChild()->Value();
621
 
                                        CLog::Log("    Share Path: %s", szPath);
 
624
                                        CLog::Log(LOGDEBUG, "    Share Path: %s", szPath);
622
625
 
623
626
                                        CShare share;
624
627
                                        share.strName=szName;
663
666
                                }
664
667
                                else
665
668
                                {
666
 
                                        CLog::Log("    <name> and/or <path> not properly defined within <bookmark>");
 
669
                                        CLog::Log(LOGERROR, "    <name> and/or <path> not properly defined within <bookmark>");
667
670
                                }
668
671
 
669
672
                        }
675
678
                                        const char* pszText=pChild->FirstChild()->Value();
676
679
                                        if (strlen(pszText) > 0)
677
680
                                                strDefault=pszText;
678
 
                                        CLog::Log("    Setting <default> share to : %s", strDefault.c_str());
 
681
                                        CLog::Log(LOGDEBUG, "    Setting <default> share to : %s", strDefault.c_str());
679
682
                                }
680
683
                        }
681
684
                        pChild=pChild->NextSibling();
683
686
        }
684
687
        else 
685
688
        {
686
 
                CLog::Log("  <%s> tag is missing or XboxMediaCenter.xml is malformed", strTagName.c_str());
 
689
                CLog::Log(LOGERROR, "  <%s> tag is missing or XboxMediaCenter.xml is malformed", strTagName.c_str());
687
690
        }
688
691
}
689
692
 
708
711
                strcpy(szValue,strDefaultValue.c_str());
709
712
        }
710
713
 
711
 
        CLog::Log("  %s: %s", strTagName.c_str(), szValue); 
 
714
        CLog::Log(LOGDEBUG, "  %s: %s", strTagName.c_str(), szValue); 
712
715
}
713
716
 
714
717
void CSettings::GetInteger(const TiXmlElement* pRootElement, const CStdString& strTagName, int& iValue, const int iDefault, const int iMin, const int iMax)
722
725
        else
723
726
                iValue=iDefault;
724
727
 
725
 
        CLog::Log("  %s: %d", strTagName.c_str(), iValue);
 
728
        CLog::Log(LOGDEBUG, "  %s: %d", strTagName.c_str(), iValue);
726
729
}
727
730
 
728
731
void CSettings::GetFloat(const TiXmlElement* pRootElement, const CStdString& strTagName, float& fValue, const float fDefault, const float fMin, const float fMax)
736
739
        else
737
740
                fValue=fDefault;
738
741
 
739
 
        CLog::Log("  %s: %f", strTagName.c_str(), fValue);
 
742
        CLog::Log(LOGDEBUG, "  %s: %f", strTagName.c_str(), fValue);
740
743
}
741
744
 
742
745
void CSettings::GetBoolean(const TiXmlElement* pRootElement, const CStdString& strTagName, bool& bValue)
840
843
                        GetInteger(pOverscan, "right", m_ResInfo[iRes].Overscan.right,m_ResInfo[iRes].iWidth,m_ResInfo[iRes].iWidth/2,m_ResInfo[iRes].iWidth*3/2);
841
844
                        GetInteger(pOverscan, "bottom", m_ResInfo[iRes].Overscan.bottom,m_ResInfo[iRes].iHeight,m_ResInfo[iRes].iHeight/2,m_ResInfo[iRes].iHeight*3/2);
842
845
                }
843
 
                CLog::Log("  calibration for %s %ix%i",m_ResInfo[iRes].strMode,m_ResInfo[iRes].iWidth,m_ResInfo[iRes].iHeight);
844
 
                CLog::Log("    subtitle yposition:%i pixelratio:%03.3f offsets:(%i,%i)->(%i,%i) osdyoffset:%i", 
 
846
                CLog::Log(LOGINFO, "  calibration for %s %ix%i",m_ResInfo[iRes].strMode,m_ResInfo[iRes].iWidth,m_ResInfo[iRes].iHeight);
 
847
                CLog::Log(LOGINFO, "    subtitle yposition:%i pixelratio:%03.3f offsets:(%i,%i)->(%i,%i) osdyoffset:%i", 
845
848
                        m_ResInfo[iRes].iSubtitles, m_ResInfo[iRes].fPixelRatio,
846
849
                        m_ResInfo[iRes].Overscan.left,m_ResInfo[iRes].Overscan.top, 
847
850
                        m_ResInfo[iRes].Overscan.right,m_ResInfo[iRes].Overscan.bottom,
1629
1632
 
1630
1633
bool CSettings::LoadProfiles(const TiXmlElement* pRootElement, const CStdString& strSettingsFile)
1631
1634
{
1632
 
        CLog::Log("  Parsing <profiles> tag");
 
1635
        CLog::Log(LOGINFO, "  Parsing <profiles> tag");
1633
1636
        const TiXmlNode *pChild = pRootElement->FirstChild("profiles");
1634
1637
        if (pChild)
1635
1638
        {
1644
1647
                                if (pProfileName && pProfileFile)
1645
1648
                                {
1646
1649
                                        const char* szName=pProfileName->FirstChild()->Value();
1647
 
                                        CLog::Log("    Profile Name: %s", szName);
 
1650
                                        CLog::Log(LOGDEBUG, "    Profile Name: %s", szName);
1648
1651
                                        const char* szPath=pProfileFile->FirstChild()->Value();
1649
 
                                        CLog::Log("    Profile Filename: %s", szPath);
 
1652
                                        CLog::Log(LOGDEBUG, "    Profile Filename: %s", szPath);
1650
1653
 
1651
1654
                                        CProfile profile;
1652
1655
          CStdString str = szName;
1657
1660
                                }
1658
1661
                                else
1659
1662
                                {
1660
 
                                        CLog::Log("    <name> and/or <file> not properly defined within <profile>");
 
1663
                                        CLog::Log(LOGERROR, "    <name> and/or <file> not properly defined within <profile>");
1661
1664
                                }
1662
1665
                        }
1663
1666
                        pChild=pChild->NextSibling();
1666
1669
        }
1667
1670
        else 
1668
1671
        {
1669
 
                CLog::Log("  <profiles> tag is missing or %s is malformed", strSettingsFile.c_str());
 
1672
                CLog::Log(LOGERROR, "  <profiles> tag is missing or %s is malformed", strSettingsFile.c_str());
1670
1673
    return false;
1671
1674
        }
1672
1675
}