From c774740dad53435aafcc543d8688e1c606a506d4 Mon Sep 17 00:00:00 2001 From: xtne6f Date: Thu, 5 Jul 2018 20:27:33 +0900 Subject: [PATCH] =?UTF-8?q?=E9=8C=B2=E7=94=BB=E3=82=BF=E3=82=B0(2ch=5FEDCB?= =?UTF-8?q?/50/226)=E7=9B=B8=E5=BD=93=E3=81=AE=E5=8B=95=E4=BD=9C=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=81=AA=E3=81=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 名前が$BatFileTag$であること以外は先行「2ch_EDCB/50/226 rectag」( https://github.com/abt8WG/EDCB/commit/e9171dddd1333928f1fdefb5d095857bbfbba8c8 )と同じ (形式的にbatFilePathに紐づいたタグにしておきたいのと、後付けするには名前が短いと思ったため) $BatFileTag$は自由度が高くなりそうなので最低限、制御文字とダブルクォートは潰しておく ついでに若干の整理と$RecInfoID$を追加 --- EpgTimerSrv/EpgTimerSrv/BatManager.cpp | 10 ++++ EpgTimerSrv/EpgTimerSrv/BatManager.h | 9 ++-- EpgTimerSrv/EpgTimerSrv/EpgTimerSrvMain.cpp | 2 + EpgTimerSrv/EpgTimerSrv/ReserveManager.cpp | 54 +++++++++++---------- EpgTimerSrv/EpgTimerSrv/ReserveManager.h | 2 +- 5 files changed, 46 insertions(+), 31 deletions(-) diff --git a/EpgTimerSrv/EpgTimerSrv/BatManager.cpp b/EpgTimerSrv/EpgTimerSrv/BatManager.cpp index 491413e693..d1f35630a3 100644 --- a/EpgTimerSrv/EpgTimerSrv/BatManager.cpp +++ b/EpgTimerSrv/EpgTimerSrv/BatManager.cpp @@ -245,6 +245,16 @@ bool CBatManager::CreateBatFile(BAT_WORK_INFO& info, LPCWSTR batFilePath, DWORD& } } } + for( size_t i = 0; i < info.macroList.size(); i++ ){ + for( size_t j = 0; j < info.macroList[i].second.size(); j++ ){ + //䕶ƃ_uNH[g͒u + if( (L'\x1' <= info.macroList[i].second[j] && info.macroList[i].second[j] <= L'\x1f') || info.macroList[i].second[j] == L'\x7f' ){ + info.macroList[i].second[j] = L''; + }else if( info.macroList[i].second[j] == L'"' ){ + info.macroList[i].second[j] = L'h'; + } + } + } if( exDirectFlag ){ exDirect = CreateEnvironment(info); return exDirect.empty() == false; diff --git a/EpgTimerSrv/EpgTimerSrv/BatManager.h b/EpgTimerSrv/EpgTimerSrv/BatManager.h index 597a088732..b4a2d09f40 100644 --- a/EpgTimerSrv/EpgTimerSrv/BatManager.h +++ b/EpgTimerSrv/EpgTimerSrv/BatManager.h @@ -2,14 +2,13 @@ #include "../../Common/ThreadUtil.h" #include "NotifyManager.h" -struct BAT_WORK_INFO { - wstring batFilePath; - vector> macroList; -}; - class CBatManager { public: + struct BAT_WORK_INFO { + wstring batFilePath; + vector> macroList; + }; CBatManager(CNotifyManager& notifyManager_, LPCWSTR tmpBatFileName); ~CBatManager(); diff --git a/EpgTimerSrv/EpgTimerSrv/EpgTimerSrvMain.cpp b/EpgTimerSrv/EpgTimerSrv/EpgTimerSrvMain.cpp index a5e33ff5b6..098b42cbca 100644 --- a/EpgTimerSrv/EpgTimerSrv/EpgTimerSrvMain.cpp +++ b/EpgTimerSrv/EpgTimerSrv/EpgTimerSrvMain.cpp @@ -1156,6 +1156,8 @@ RESERVE_DATA CEpgTimerSrvMain::GetDefaultReserveData(__int64 startTime) const r.recSetting.endMargine = this->setting.endMargin; r.recSetting.serviceMode = (this->setting.enableCaption ? RECSERVICEMODE_CAP : 0) | (this->setting.enableData ? RECSERVICEMODE_DATA : 0) | RECSERVICEMODE_SET; + //*ȍ~BatFileTagƂĈƂ + r.recSetting.batFilePath = L"*"; return r; } diff --git a/EpgTimerSrv/EpgTimerSrv/ReserveManager.cpp b/EpgTimerSrv/EpgTimerSrv/ReserveManager.cpp index 05ef5e3116..11ca505bbd 100644 --- a/EpgTimerSrv/EpgTimerSrv/ReserveManager.cpp +++ b/EpgTimerSrv/EpgTimerSrv/ReserveManager.cpp @@ -176,7 +176,7 @@ bool CReserveManager::AddReserveData(const vector& reserveList, bo bool modified = false; __int64 minStartTime = LLONG_MAX; __int64 now = GetNowI64Time(); - vector batWorkList; + vector batWorkList; for( size_t i = 0; i < reserveList.size(); i++ ){ RESERVE_DATA r = reserveList[i]; //łɏIĂȂ @@ -216,7 +216,7 @@ bool CReserveManager::ChgReserveData(const vector& reserveList, bo bool modified = false; __int64 minStartTime = LLONG_MAX; - vector batWorkList; + vector batWorkList; for( size_t i = 0; i < reserveList.size(); i++ ){ RESERVE_DATA r = reserveList[i]; map::const_iterator itr = this->reserveText.GetMap().find(r.reserveID); @@ -1216,7 +1216,7 @@ void CReserveManager::CheckOverTimeReserve() void CReserveManager::ProcessRecEnd(const vector& retList, int* shutdownMode) { - vector batWorkList; + vector batWorkList; bool modified = false; for( auto itrRet = retList.cbegin(); itrRet != retList.end(); itrRet++ ){ map::const_iterator itrRes = this->reserveText.GetMap().find(itrRet->reserveID); @@ -1278,26 +1278,28 @@ void CReserveManager::ProcessRecEnd(const vector& item.recStatus = REC_END_STATUS_START_ERR; break; } - this->recInfoText.AddRecInfo(item); + item.id = this->recInfoText.AddRecInfo(item); //ob`lj - BAT_WORK_INFO batInfo; + CBatManager::BAT_WORK_INFO batInfo; AddRecInfoMacro(batInfo.macroList, item); batInfo.macroList.push_back(pair("AddKey", itrRes->second.comment.compare(0, 8, L"EPG\(") == 0 && itrRes->second.comment.find(L')') != wstring::npos ? itrRes->second.comment.substr(8, itrRes->second.comment.find(L')') - 8) : wstring())); - if( (itrRet->type == CTunerBankCtrl::CHECK_END || itrRet->type == CTunerBankCtrl::CHECK_END_NEXT_START_END || this->setting.errEndBatRun) && - item.recFilePath.empty() == false && itrRes->second.recSetting.batFilePath.empty() == false && itrRet->continueRec == false ){ - batInfo.batFilePath = itrRes->second.recSetting.batFilePath; - this->batManager.AddBatWork(batInfo); - } + batInfo.macroList.push_back(pair("BatFileTag", + itrRes->second.recSetting.batFilePath.find(L'*') != wstring::npos ? + itrRes->second.recSetting.batFilePath.substr(itrRes->second.recSetting.batFilePath.find(L'*') + 1) : wstring())); if( itrRet->type != CTunerBankCtrl::CHECK_ERR_PASS ){ - batWorkList.resize(batWorkList.size() + 1); - batWorkList.back().macroList = batInfo.macroList; + batWorkList.push_back(batInfo); if( shutdownMode ){ *shutdownMode = MAKEWORD(itrRes->second.recSetting.suspendMode, itrRes->second.recSetting.rebootFlag); } } + batInfo.batFilePath.assign(itrRes->second.recSetting.batFilePath, 0, itrRes->second.recSetting.batFilePath.find(L'*')); + if( (itrRet->type == CTunerBankCtrl::CHECK_END || itrRet->type == CTunerBankCtrl::CHECK_END_NEXT_START_END || this->setting.errEndBatRun) && + item.recFilePath.empty() == false && batInfo.batFilePath.empty() == false && itrRet->continueRec == false ){ + this->batManager.AddBatWork(batInfo); + } this->reserveText.DelReserve(itrRes->first); this->reserveModified = true; @@ -1341,7 +1343,7 @@ DWORD CReserveManager::Check() CTunerBankCtrl::TR_STATE state = itrBank->second->GetState(); isRec = isRec || state == CTunerBankCtrl::TR_REC; isEpgCap = isEpgCap || state == CTunerBankCtrl::TR_EPGCAP; - vector batWorkList; + vector batWorkList; for( size_t i = 0; i < startedReserveIDList.size(); i++ ){ map::const_iterator itrRes = this->reserveText.GetMap().find(startedReserveIDList[i]); if( itrRes != this->reserveText.GetMap().end() ){ @@ -1866,7 +1868,7 @@ void CReserveManager::WatchdogThread(CReserveManager* sys) } } -void CReserveManager::AddPostBatWork(vector& workList, LPCWSTR fileName) +void CReserveManager::AddPostBatWork(vector& workList, LPCWSTR fileName) { if( workList.empty() == false ){ fs_path batFilePath = GetModulePath().replace_filename(fileName); @@ -1884,7 +1886,7 @@ void CReserveManager::AddPostBatWork(vector& workList, LPCWSTR fi void CReserveManager::AddNotifyAndPostBat(DWORD notifyID) { this->notifyManager.AddNotify(notifyID); - vector workList(1); + vector workList(1); workList[0].macroList.push_back(pair("NotifyID", L"")); Format(workList[0].macroList.back().second, L"%d", notifyID); AddPostBatWork(workList, L"PostNotify.bat"); @@ -1935,12 +1937,16 @@ void CReserveManager::AddReserveDataMacro(vector>& macroLi macroList.push_back(std::make_pair(string("Title") + suffix, data.title)); macroList.push_back(std::make_pair(string("ServiceName") + suffix, data.stationName)); macroList.push_back(std::make_pair(string("ReserveComment") + suffix, data.comment)); + macroList.push_back(std::make_pair(string("BatFileTag") + suffix, + data.recSetting.batFilePath.find(L'*') != wstring::npos ? + data.recSetting.batFilePath.substr(data.recSetting.batFilePath.find(L'*') + 1) : wstring())); } void CReserveManager::AddRecInfoMacro(vector>& macroList, const REC_FILE_INFO& recInfo) { WCHAR v[64]; AddTimeMacro(macroList, recInfo.startTime, recInfo.durationSecond, ""); + swprintf_s(v, L"%d", recInfo.id); macroList.push_back(pair("RecInfoID", v)); swprintf_s(v, L"%d", recInfo.originalNetworkID); macroList.push_back(pair("ONID10", v)); swprintf_s(v, L"%d", recInfo.transportStreamID); macroList.push_back(pair("TSID10", v)); swprintf_s(v, L"%d", recInfo.serviceID); macroList.push_back(pair("SID10", v)); @@ -1958,18 +1964,16 @@ void CReserveManager::AddRecInfoMacro(vector>& macroList, fs_path path = recInfo.recFilePath; macroList.push_back(pair("FolderPath", path.parent_path().native())); macroList.push_back(pair("FileName", path.stem().native())); - wstring strVal = recInfo.title; - CheckFileName(strVal); - macroList.push_back(pair("TitleF", strVal)); - strVal = recInfo.title; - while( strVal.find(L'[') != wstring::npos && strVal.find(L']') != wstring::npos ){ + macroList.push_back(pair("TitleF", recInfo.title)); + CheckFileName(macroList.back().second); + macroList.push_back(pair("Title2", recInfo.title)); + while( macroList.back().second.find(L'[') != wstring::npos && macroList.back().second.find(L']') != wstring::npos ){ wstring strSep1; wstring strSep2; - Separate(strVal, L"[", strVal, strSep1); + Separate(macroList.back().second, L"[", macroList.back().second, strSep1); Separate(strSep1, L"]", strSep2, strSep1); - strVal += strSep1; + macroList.back().second += strSep1; } - macroList.push_back(pair("Title2", strVal)); - CheckFileName(strVal); - macroList.push_back(pair("Title2F", strVal)); + macroList.push_back(pair("Title2F", macroList.back().second)); + CheckFileName(macroList.back().second); } diff --git a/EpgTimerSrv/EpgTimerSrv/ReserveManager.h b/EpgTimerSrv/EpgTimerSrv/ReserveManager.h index 40fce4268a..ced01be930 100644 --- a/EpgTimerSrv/EpgTimerSrv/ReserveManager.h +++ b/EpgTimerSrv/EpgTimerSrv/ReserveManager.h @@ -138,7 +138,7 @@ class CReserveManager //oNĎĕKvȂ`[iIXbh static void WatchdogThread(CReserveManager* sys); //batPostManagerɃob`lj - void AddPostBatWork(vector& workList, LPCWSTR fileName); + void AddPostBatWork(vector& workList, LPCWSTR fileName); //ob`ɓn}Nlj static void AddTimeMacro(vector>& macroList, const SYSTEMTIME& startTime, DWORD durationSecond, LPCSTR suffix); //ob`ɓn\}Nlj