Exemplo n.º 1
0
ProcessDataStatus TVSearchMgr::ProcessData()
{
	// 从栈中取数,处理,删除的结构用指针操作,会快一些
	DVBSection *pSection = GetSection();
	if(pSection == NULL )
	{
		dxreport("TVSearchMgrPollProc: pSection is NULL.\n");
		return PDS_WAIT_DATA;
	}

	//处理数据一定要快,否则可能阻塞或增加耗时
	// 本来需要处理deque中的所有数据, 但考虑数据的同步性,处理
	// 一个section 数据后程序会改变执行流程,所以只处理了一个数据。
	// 但考虑至少99%以上deque 只会存一个数据。多余浪费的数据只会增加一点时间
	// 所以该程序结构不会有问题
	int iFlag = analyse_section_data(pSection->pid_,pSection->data_,pSection->dataLen_); 

	U16 pid = pSection->pid_ ; 
	U8  talbe_id = pSection->table_id_;
	FreeSection(pSection);

	if(iFlag == RT_CONTINUE) 
		return PDS_WAIT_DATA;


	// 分析数据后,如果table_id 不是PMT table, 就删除该searcher
	if(talbe_id != 0x02) 
	{
		RemoveOneSearcher(pid,talbe_id);
		RemoveSection(pid, talbe_id); // 增加删除section 中多余数据
	}
	switch(iFlag)
	{
		case  RT_UPDATE_FILTER:  /// 手工或全频搜索pat分析完成,需要搜索新的过滤表(PMT filters)
//			BuildSearchers(BS_PMT);
			return PDS_PATCATSDT_READY;
		case RT_TABLE_OK:			// 表分析完成,等待服务分析完成
			return PDS_WAIT_DATA;
		case RT_SERVICE_OK :		/// 某频点分析完成,退出switch,清理searcher, 进行下一频点搜索
			OnDVBService();
			break;
		case RT_UPDATE_FREQ:	    

			break;
		default:		// 不会有
			;
	}
	ClearSearchers();	
	return PDS_DATA_READY;
	
}
Exemplo n.º 2
0
//------------------------------------------------------------------------
//! Removes a profile from the official list of column configuration profiles
//!
//! @param strProfile Name of the profile
//------------------------------------------------------------------------
void CViewConfigSectionProfiles::DeleteProfile(const CString& strProfile)
{
	if (strProfile.IsEmpty())
		return;

	// Remove any settings
	RemoveSection(JoinSectionName(m_ViewName, strProfile));

	// Remove the strProfile from the list
	CSimpleArray<CString> profiles;
	GetProfiles(profiles);
	for (int i = 0; i < profiles.GetSize(); ++i)
		if (profiles[i] == strProfile)
			profiles.RemoveAt(i);
	WriteSetting(m_ViewName, _T("CurrentProfiles"), ConvertArraySetting(profiles, _T(", ")));
}
Exemplo n.º 3
0
//------------------------------------------------------------------------
//! Resets the current configuration by deleting it and restoring it
//! from the in memory default configuration.
//------------------------------------------------------------------------
void CViewConfigSectionDefault::ResetConfigDefault()
{
	RemoveSection(GetSectionName());
	m_DefaultConfig.CopySettings(*this);
}
Exemplo n.º 4
0
//------------------------------------------------------------------------
//! Removes the current configuration
//------------------------------------------------------------------------
void CViewConfigSection::RemoveCurrentConfig()
{
	RemoveSection(GetSectionName());
}
Exemplo n.º 5
0
bool MapFile::SaveFile(bool SaveAs)
{
    if ( isProtected() )
        MessageBox(NULL, "Cannot save protected maps!", "Error!", MB_OK|MB_ICONEXCLAMATION);
    else
    {
        if ( SaveAs || filePath[0] == '\0' ) // SaveAs specified or filePath not yet determined
        {
            OPENFILENAME ofn = GetScSaveOfn(filePath);
            if ( GetSaveFileName(&ofn) )
            {
                SaveType = (u8)ofn.nFilterIndex;

                char* ext = std::strrchr(filePath, '.'); // Find the last occurrence of '.'
                if ( ext == nullptr ) // No extension specified, need to add
                {
                    if ( SaveType == 1 || SaveType == 2 )
                        std::strcat(filePath, ".scm");
                    else if ( SaveType == 3 || SaveType == 7 )
                        std::strcat(filePath, ".scx");
                    else if ( SaveType >= 4 && SaveType <= 6 )
                        std::strcat(filePath, ".chk");
                }
                else // Extension specified, give it precedence over filterIndex
                {
                    if ( std::strcmp(ext, ".chk") == 0 && SaveType < 4 )
                        SaveType = 5;
                    else if ( std::strcmp(ext, ".scm") == 0 && SaveType > 1 )
                        SaveType = 2;
                    else if ( std::strcmp(ext, ".scx") == 0 )
                        SaveType = 3;
                    else if ( SaveType == 7 )
                        SaveType = 3;
                }
            }
        }

        if ( filePath[0] != '\0' ) // Map for sure has a path
        {
            FILE* pFile(nullptr);

            if ( SaveType == 1 || SaveType == 4 ) // StarCraft Map, edit to match
            {
                TYPE().overwrite("RAWS", 4);
                VER ().overwrite(";\0", 2);
                IVER().overwrite("\12\0", 2);
                IVE2().overwrite("\13\0", 2);

                if ( MRGN().size() > 1280 ) // If there's over 64 locations
                    MRGN().delRange(1280, MRGN().size()); // Remove the extras
            }
            else if ( SaveType == 2 || SaveType == 5 ) // Hybrid Map, edit to match
            {
                TYPE().overwrite("RAWS", 4);
                VER ().overwrite("?\0", 2);
                IVER().overwrite("\12\0", 2);
                IVE2().overwrite("\13\0", 2);

                if ( MRGN().size() < 5100 ) // If there's < 255 locations
                    MRGN().add<u8>(0, 5100-MRGN().size()); // Add space for 255
            }
            else if ( SaveType == 3 || SaveType == 6 || SaveType == 7 ) // BroodWar Map, edit to match
            {
                TYPE().overwrite("RAWB", 4);
                VER ().overwrite("Í\0", 2);
                RemoveSection(SectionId::IVER);
                IVE2().overwrite("\13\0", 2);

                if ( MRGN().size() < 5100 ) // If there's < 255 locations
                    MRGN().add<u8>(0, 5100-MRGN().size()); // Add space for 255
            }

            if ( (SaveType > 0 && SaveType <= 3) || SaveType == 7 ) // Must be packed into an MPQ
            {
                pFile = std::fopen(filePath, "wb");
                if ( pFile != nullptr )
                {
                    std::fclose(pFile);
                    HANDLE hMpq = NULL;
                    DeleteFileA("chk.tmp"); // Remove any existing chk.tmp files
                    pFile = std::fopen("chk.tmp", "wb");
                    WriteFile(pFile);
                    std::fclose(pFile);

                    hMpq = MpqOpenArchiveForUpdate(filePath, MOAU_OPEN_ALWAYS|MOAU_MAINTAIN_LISTFILE, 16);
                    if ( hMpq != NULL && hMpq != INVALID_HANDLE_VALUE )
                    {
                        BOOL addedFile = MpqAddFileToArchive(hMpq, "chk.tmp", "staredit\\scenario.chk", MAFA_COMPRESS | MAFA_REPLACE_EXISTING);
                        MpqCloseUpdatedArchive(hMpq, 0);

                        if ( addedFile == TRUE )
                        {
                            DeleteFileA("chk.tmp");
                            return true;
                        }
                        else
                            MessageBox(NULL, "Failed to add file!", "Error!", MB_OK|MB_ICONEXCLAMATION);
                    }
                    else
                        MessageBox(NULL, "Failed to open for updates!", "Error!", MB_OK|MB_ICONEXCLAMATION);

                    DeleteFileA("chk.tmp");
                }
                else
                    MessageBox(NULL, "Failed to open file!\n\nThe file may be in use elsewhere.", "Error!", MB_OK|MB_ICONEXCLAMATION);
            }
            else // Is a chk file or unrecognized format, write out chk file
            {
                DeleteFileA(filePath); // Remove any existing files of the same name
                pFile = std::fopen(filePath, "wb");
                WriteFile(pFile);
                std::fclose(pFile);
                return true;
            }
        }
    }
    return false;
}