Пример #1
0
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;
}
Пример #2
0
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;
}
Пример #3
0
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;
}
Пример #4
0
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;
}
Пример #5
0
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;
}