bool CControllerManager::SaveControllerSettings(LPCTSTR pszName) const { int Index=FindController(pszName); if (Index<0) return false; const ControllerInfo &Info=m_ControllerList[Index]; if (!Info.fSettingsChanged) return true; CSettings Settings; TCHAR szFileName[MAX_PATH]; if (!Info.pController->GetIniFileName(szFileName,lengthof(szFileName))) return false; if (Settings.Open(szFileName,CSettings::OPEN_WRITE) && Settings.SetSection(Info.pController->GetIniFileSection())) { const int NumButtons=Info.pController->NumButtons(); const CCommandList &CommandList=GetAppClass().CommandList; for (int i=0;i<NumButtons;i++) { TCHAR szName[64]; LPCTSTR pszText=NULL; ::wsprintf(szName,TEXT("Button%d_Command"),i); if (Info.Settings.AssignList[i]!=0) pszText=CommandList.GetCommandTextByID(Info.Settings.AssignList[i]); Settings.Write(szName,pszText!=NULL?pszText:TEXT("")); } if (!Info.pController->IsActiveOnly()) Settings.Write(TEXT("ActiveOnly"),Info.Settings.fActiveOnly); } return true; }
bool CChannelManager::LoadChannelSettings(LPCTSTR pszFileName,LPCTSTR pszDriverName) { if (m_TuningSpaceList.IsEmpty() || m_fChannelFileHasStreamIDs) return true; CSettings Settings; int SpaceCount; TRACE(TEXT("ストリーム情報の読み込み : \"%s\" [%s]\n"),pszFileName,pszDriverName); if (!Settings.Open(pszFileName,CSettings::OPEN_READ) || !Settings.SetSection(::PathFindFileName(pszDriverName))) return false; if (Settings.Read(TEXT("SpaceCount"),&SpaceCount) && SpaceCount>0) { for (int i=0;i<SpaceCount;i++) { int NumChannels; TCHAR szName[64]; ::wsprintf(szName,TEXT("Space%d_Count"),i); if (Settings.Read(szName,&NumChannels) && NumChannels>0) { for (int j=0;j<NumChannels;j++) { int ChannelIndex; int NumServices; unsigned int NetworkID,TSID,ServiceID; ::wsprintf(szName,TEXT("Space%d_ChannelMap%d"),i,j); if (Settings.Read(szName,&ChannelIndex)) { ::wsprintf(szName,TEXT("Space%d_Channel%d_NID"),i,ChannelIndex); if (!Settings.Read(szName,&NetworkID)) NetworkID=0; ::wsprintf(szName,TEXT("Space%d_Channel%d_TSID"),i,ChannelIndex); if (!Settings.Read(szName,&TSID)) TSID=0; if (NetworkID!=0 || TSID!=0) { ::wsprintf(szName,TEXT("Space%d_Channel%d_Count"),i,ChannelIndex); if (Settings.Read(szName,&NumServices) && NumServices>0) { for (int k=0;k<NumServices;k++) { ::wsprintf(szName,TEXT("Space%d_Channel%d_Service%d_SID"),i,ChannelIndex,k); if (Settings.Read(szName,&ServiceID) && ServiceID!=0) UpdateStreamInfo(i,ChannelIndex,NetworkID,TSID,ServiceID); } } } } } } } } return true; }
bool CDriverManager::LoadTunerSpec(LPCTSTR pszFileName) { CSettings Settings; if (!Settings.Open(pszFileName,CSettings::OPEN_READ) || !Settings.SetSection(TEXT("TunerSpec"))) return false; CSettings::EntryList Entries; if (!Settings.GetEntries(&Entries)) return false; for (auto it=Entries.begin();it!=Entries.end();++it) { TunerSpecInfo Info; Info.TunerMask=it->Name; Info.Spec.Flags=0; std::vector<TVTest::String> Attributes; if (TVTest::StringUtility::Split(it->Value,TEXT("|"),&Attributes)) { static const struct { LPCTSTR pszName; unsigned int Flag; } FlagList[] = { {TEXT("network"), TunerSpec::FLAG_NETWORK}, {TEXT("file"), TunerSpec::FLAG_FILE}, {TEXT("virtual"), TunerSpec::FLAG_VIRTUAL}, {TEXT("volatile"), TunerSpec::FLAG_VOLATILE}, {TEXT("no-enum-channel"), TunerSpec::FLAG_NOENUMCHANNEL}, }; for (int i=0;i<lengthof(FlagList);i++) { for (auto itAttr=Attributes.begin();itAttr!=Attributes.end();++itAttr) { TVTest::StringUtility::Trim(*itAttr); if (TVTest::StringUtility::CompareNoCase(*itAttr,FlagList[i].pszName)==0) { Info.Spec.Flags|=FlagList[i].Flag; break; } } } } m_TunerSpecList.push_back(Info); } return true; }
bool CControllerManager::LoadControllerSettings(LPCTSTR pszName) { int Index=FindController(pszName); if (Index<0) return false; ControllerInfo &Info=m_ControllerList[Index]; if (Info.fSettingsLoaded) return true; CSettings Settings; TCHAR szFileName[MAX_PATH]; if (!Info.pController->GetIniFileName(szFileName,lengthof(szFileName))) return false; if (Settings.Open(szFileName,CSettings::OPEN_READ) && Settings.SetSection(Info.pController->GetIniFileSection())) { const int NumButtons=Info.pController->NumButtons(); const CCommandList &CommandList=GetAppClass().CommandList; for (int i=0;i<NumButtons;i++) { TCHAR szName[64],szCommand[CCommandList::MAX_COMMAND_TEXT]; ::wsprintf(szName,TEXT("Button%d_Command"),i); if (Settings.Read(szName,szCommand,lengthof(szCommand)) && szCommand[0]!='\0') { Info.Settings.AssignList[i]=CommandList.ParseText(szCommand); } } if (!Info.pController->IsActiveOnly()) Settings.Read(TEXT("ActiveOnly"),&Info.Settings.fActiveOnly); Info.fSettingsLoaded=true; } return true; }
bool CColorScheme::Load(LPCTSTR pszFileName,bool fLegacy) { CSettings Settings; TCHAR szText[MAX_COLORSCHEME_NAME]; int i; if (!Settings.Open(pszFileName,TEXT("ColorScheme"),CSettings::OPEN_READ)) return false; if (Settings.Read(TEXT("Name"),szText,lengthof(szText))) SetName(szText); ::ZeroMemory(m_LoadedFlags,sizeof(m_LoadedFlags)); for (i=0;i<NUM_COLORS;i++) { if (Settings.ReadColor((fLegacy?m_ColorInfoLegacyList:m_ColorInfoList)[i].pszText,&m_ColorList[i])) SetLoadedFlag(i); } for (i=0;i<NUM_COLORS;i++) { if (IsLoaded(i)) { for (int j=0;j<NUM_GRADIENTS;j++) { if (m_GradientInfoList[j].Color1==i || m_GradientInfoList[j].Color2==i) { if (m_GradientInfoList[j].Color1==i && !IsLoaded(m_GradientInfoList[j].Color2)) { m_ColorList[m_GradientInfoList[j].Color2]=m_ColorList[i]; SetLoadedFlag(m_GradientInfoList[j].Color2); } m_GradientList[j].Type=Theme::GRADIENT_NORMAL; break; } } } else { static const struct { int To,From; } Map[] = { // {COLOR_STATUSBORDER, COLOR_STATUSBACK1}, {COLOR_STATUSBOTTOMITEMBACK1, COLOR_STATUSBACK2}, {COLOR_STATUSBOTTOMITEMBACK2, COLOR_STATUSBOTTOMITEMBACK1}, {COLOR_STATUSBOTTOMITEMTEXT, COLOR_STATUSTEXT}, {COLOR_STATUSBOTTOMITEMBORDER, COLOR_STATUSBOTTOMITEMBACK1}, }; static const struct { int To,From1,From2; } MixMap[] = { {COLOR_STATUSBORDER, COLOR_STATUSBACK1, COLOR_STATUSBACK2}, }; bool fFound=false; for (int j=0;j<lengthof(Map);j++) { if (Map[j].To==i && IsLoaded(Map[j].From)) { m_ColorList[i]=m_ColorList[Map[j].From]; SetLoadedFlag(i); fFound=true; break; } } if (!fFound) { for (int j=0;j<lengthof(MixMap);j++) { if (MixMap[j].To==i && IsLoaded(MixMap[j].From1) && IsLoaded(MixMap[j].From2)) { m_ColorList[i]=MixColor(m_ColorList[MixMap[j].From1],m_ColorList[MixMap[j].From2]); SetLoadedFlag(i); break; } } } } } for (i=0;i<NUM_GRADIENTS;i++) { if (Settings.Read(m_GradientInfoList[i].pszText,szText,lengthof(szText))) { if (szText[0]=='\0' || ::lstrcmpi(szText,TEXT("normal"))==0) m_GradientList[i].Type=Theme::GRADIENT_NORMAL; else if (::lstrcmpi(szText,TEXT("glossy"))==0) m_GradientList[i].Type=Theme::GRADIENT_GLOSSY; else if (::lstrcmpi(szText,TEXT("interlaced"))==0) m_GradientList[i].Type=Theme::GRADIENT_INTERLACED; } TCHAR szName[128]; ::wsprintf(szName,TEXT("%sDirection"),m_GradientInfoList[i].pszText); m_GradientList[i].Direction=m_GradientInfoList[i].Direction; if (Settings.Read(szName,szText,lengthof(szText))) { for (int j=0;j<lengthof(GradientDirectionList);j++) { if (::lstrcmpi(szText,GradientDirectionList[j])==0) { m_GradientList[i].Direction=(Theme::GradientDirection)j; break; } } } } Settings.Close(); for (i=0;i<NUM_BORDERS;i++) m_BorderList[i]=m_BorderInfoList[i].DefaultType; if (Settings.Open(pszFileName,TEXT("Style"),CSettings::OPEN_READ)) { for (i=0;i<NUM_BORDERS;i++) { if (Settings.Read(m_BorderInfoList[i].pszText,szText,lengthof(szText))) { if (::lstrcmpi(szText,TEXT("none"))==0) { if (!m_BorderInfoList[i].fAlways) m_BorderList[i]=Theme::BORDER_NONE; } else if (::lstrcmpi(szText,TEXT("solid"))==0) m_BorderList[i]=Theme::BORDER_SOLID; else if (::lstrcmpi(szText,TEXT("sunken"))==0) m_BorderList[i]=Theme::BORDER_SUNKEN; else if (::lstrcmpi(szText,TEXT("raised"))==0) m_BorderList[i]=Theme::BORDER_RAISED; } } Settings.Close(); } SetFileName(pszFileName); return true; }
bool CChannelManager::SaveChannelSettings(LPCTSTR pszFileName,LPCTSTR pszDriverName) { if (m_TuningSpaceList.IsEmpty() || m_fChannelFileHasStreamIDs) return true; CSettings Settings; int SpaceCount; TRACE(TEXT("ストリーム情報の保存 : \"%s\" [%s]\n"),pszFileName,pszDriverName); if (!Settings.Open(pszFileName,CSettings::OPEN_WRITE) || !Settings.SetSection(::PathFindFileName(pszDriverName))) return false; SpaceCount=m_TuningSpaceList.NumSpaces(); Settings.Clear(); Settings.Write(TEXT("SpaceCount"),SpaceCount); for (int i=0;i<SpaceCount;i++) { const CChannelList *pList=m_TuningSpaceList.GetChannelList(i); int NumChannels=pList->NumChannels(); TCHAR szName[64]; ::wsprintf(szName,TEXT("Space%d_Count"),i); Settings.Write(szName,NumChannels); int LastIndex=0; for (int j=0;j<NumChannels;j++) { int Index=pList->GetChannelIndex(j); if (Index>LastIndex) LastIndex=Index; } int *pServiceCount=new int[LastIndex+1]; int Map=0; for (int j=0;j<=LastIndex;j++) { int NumServices=0; for (int k=0;k<NumChannels;k++) { if (pList->GetChannelIndex(k)==j) NumServices++; } if (NumServices>0) { ::wsprintf(szName,TEXT("Space%d_ChannelMap%d"),i,Map++); Settings.Write(szName,j); ::wsprintf(szName,TEXT("Space%d_Channel%d_Count"),i,j); Settings.Write(szName,NumServices); } pServiceCount[j]=0; } for (int j=0;j<NumChannels;j++) { const CChannelInfo *pChInfo=pList->GetChannelInfo(j); if (pChInfo->GetNetworkID()!=0) { ::wsprintf(szName,TEXT("Space%d_Channel%d_NID"), pChInfo->GetSpace(),pChInfo->GetChannelIndex()); Settings.Write(szName,pChInfo->GetNetworkID()); } if (pChInfo->GetTransportStreamID()!=0) { ::wsprintf(szName,TEXT("Space%d_Channel%d_TSID"), pChInfo->GetSpace(),pChInfo->GetChannelIndex()); Settings.Write(szName,pChInfo->GetTransportStreamID()); } if (pChInfo->GetServiceID()!=0) { ::wsprintf(szName,TEXT("Space%d_Channel%d_Service%d_SID"), pChInfo->GetSpace(),pChInfo->GetChannelIndex(), pServiceCount[pChInfo->GetChannelIndex()]); Settings.Write(szName,pChInfo->GetServiceID()); } pServiceCount[pChInfo->GetChannelIndex()]++; } delete [] pServiceCount; } return true; }