Skip to content

Commit

Permalink
ロゴ関連のインタフェースを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
xtne6f committed Oct 5, 2020
1 parent 987eaae commit 695d6d3
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 10 deletions.
53 changes: 48 additions & 5 deletions EpgTimerSrv/EpgTimerSrv/EpgTimerSrvMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2890,12 +2890,14 @@ bool CEpgTimerSrvMain::CtrlCmdProcessCompatible(CMD_STREAM& cmdParam, CMD_STREAM
DWORD readSize;
if( ReadVALUE(&ver, cmdParam.data, cmdParam.dataSize, &readSize) ){
vector<wstring> list;
if( ReadVALUE2(ver, &list, cmdParam.data.get() + readSize, cmdParam.dataSize - readSize, NULL) && list.size() < 32 ){
if( ReadVALUE2(ver, &list, cmdParam.data.get() + readSize, cmdParam.dataSize - readSize, NULL) ){
//転送サイズがtotalSizeRemainより大きい場合、結果はトリムされる
size_t totalSizeRemain = 256 * 1024 * 1024;
vector<FILE_DATA> result(list.size());
for( size_t i = 0; i < list.size(); i++ ){
result[i].Name = list[i];
fs_path path;
if( UtilComparePath(list[i].c_str(), L"ChSet5.txt") == 0 ){
if( UtilComparePath(list[i].c_str(), L"ChSet5.txt") == 0 ||
UtilComparePath(list[i].c_str(), LOGO_SAVE_FOLDER L".ini") == 0 ){
path = GetSettingPath().append(list[i]);
}else if( UtilComparePath(list[i].c_str(), L"EpgTimerSrv.ini") == 0 ||
UtilComparePath(list[i].c_str(), L"Common.ini") == 0 ||
Expand All @@ -2904,9 +2906,39 @@ bool CEpgTimerSrvMain::CtrlCmdProcessCompatible(CMD_STREAM& cmdParam, CMD_STREAM
UtilComparePath(list[i].c_str(), L"ViewApp.ini") == 0 ||
UtilComparePath(list[i].c_str(), L"Bitrate.ini") == 0 ){
path = GetCommonIniPath().replace_filename(list[i]);
}else{
//ロゴフォルダに対する特例
size_t namePos = array_size(LOGO_SAVE_FOLDER L"\\") - 1;
if( list[i].size() > namePos && UtilComparePath(list[i].substr(0, namePos).c_str(), LOGO_SAVE_FOLDER L"\\") == 0 ){
path = GetSettingPath().append(LOGO_SAVE_FOLDER);
wstring name = list[i].substr(namePos);
if( name != L"*.*" ){
CheckFileName(name);
}
path.append(name);
}
}
if( path.empty() == false ){
if( UtilPathEndsWith(path.c_str(), L".ini") ){
if( UtilPathEndsWith(path.c_str(), L"*.*") ){
//ファイルリストを返す
wstring strData = L"\xFEFF";
EnumFindFile(path, [&strData](UTIL_FIND_DATA& findData) -> bool {
WCHAR prop[64];
swprintf_s(prop, L"%d %lld %lld ",
findData.isDir ? 1 : 0, findData.lastWriteTime + I64_UTIL_TIMEZONE, findData.fileSize);
strData += prop;
strData += findData.fileName;
strData += L"\r\n";
return true;
});
if( totalSizeRemain < strData.size() ){
result.resize(i);
break;
}
totalSizeRemain -= strData.size();
//BOMつきUTF-16
result[i].Data.assign((const BYTE*)strData.c_str(), (const BYTE*)(strData.c_str() + strData.size()));
}else if( UtilPathEndsWith(path.c_str(), L".ini") ){
//ファイルロックを邪魔しないようAPI経由で読む
wstring strData = L"\xFEFF";
int appendModulePathState = UtilComparePath(path.filename().c_str(), L"Common.ini") == 0;
Expand All @@ -2933,14 +2965,24 @@ bool CEpgTimerSrvMain::CtrlCmdProcessCompatible(CMD_STREAM& cmdParam, CMD_STREAM
strData += L"[SET]\r\nModulePath=\"" + GetCommonIniPath().parent_path().native() + L"\"\r\n";
}
if( strData.size() > 1 ){
if( totalSizeRemain < strData.size() ){
result.resize(i);
break;
}
totalSizeRemain -= strData.size();
//BOMつきUTF-16
result[i].Data.assign((const BYTE*)strData.c_str(), (const BYTE*)(strData.c_str() + strData.size()));
}
}else{
std::unique_ptr<FILE, decltype(&fclose)> fp(UtilOpenFile(path, UTIL_SECURE_READ), fclose);
if( fp && _fseeki64(fp.get(), 0, SEEK_END) == 0 ){
__int64 fileSize = _ftelli64(fp.get());
if( 0 < fileSize && fileSize < 16 * 1024 * 1024 ){
if( 0 < fileSize ){
if( (__int64)totalSizeRemain < fileSize ){
result.resize(i);
break;
}
totalSizeRemain -= (size_t)fileSize;
result[i].Data.resize((size_t)fileSize);
rewind(fp.get());
if( fread(&result[i].Data.front(), 1, (size_t)fileSize, fp.get()) != (size_t)fileSize ){
Expand All @@ -2950,6 +2992,7 @@ bool CEpgTimerSrvMain::CtrlCmdProcessCompatible(CMD_STREAM& cmdParam, CMD_STREAM
}
}
}
result[i].Name.swap(list[i]);
}
resParam.data = NewWriteVALUE2WithVersion(ver, result, resParam.dataSize);
resParam.param = CMD_SUCCESS;
Expand Down
39 changes: 34 additions & 5 deletions ini/HttpPublic/legacy/logo.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,47 @@
-- 局ロゴを転送するスクリプト

-- LogoData.iniとLogoフォルダがあるフォルダの絶対パス
-- 未指定のとき局ロゴは公開フォルダ下の"img/logo/ONIDSID{.png|.bmp}"と仮定
-- EDCBのロゴフォルダにロゴがないときに検索する、LogoData.iniとLogoフォルダがあるフォルダの絶対パス
-- 未指定のときは公開フォルダ下の"img/logo/ONIDSID{.png|.bmp}"が使われる
--LOGO_DIR=edcb.GetPrivateProfile('SET','ModulePath','','Common.ini')..'\\..\\TVTest'

dofile(mg.script_name:gsub('[^\\/]*$','')..'util.lua')

onid=GetVarInt(mg.request_info.query_string,'onid',0,65535) or 0
sid=GetVarInt(mg.request_info.query_string,'sid',0,65535) or 0

if LOGO_DIR then
-- ロゴ識別とServiceIDとの対応を調べる
ddid=tonumber(edcb.GetPrivateProfile('LogoIDMap',('%04X%04X'):format(onid,sid),'','Setting\\LogoData.ini'))
if ddid then
dir=edcb.GetPrivateProfile('SET','DataSavePath','','Common.ini')
if dir=='' then
dir=edcb.GetPrivateProfile('SET','ModulePath','','Common.ini')..'\\Setting'
end
dir=dir..'\\LogoData\\'
ff=edcb.FindFile(dir..('%04X_%03X_*'):format(onid,ddid),6) or {}
-- ファイル名の末尾2桁はロゴタイプ(STD-B21)
for i,v in ipairs({'05%.png','02%.png','04%.png','01%.png','03%.png','00%.png'}) do
for j,w in ipairs(ff) do
if w.name:lower():find(v..'$') then
fname=w.name
break
end
end
if fname then
f=edcb.io.open(dir..fname,'rb')
if f then
logo=f:read('*a')
f:close()
end
break
end
end
end

if not logo and LOGO_DIR then
fname=nil
f=edcb.io.open(LOGO_DIR..'\\LogoData.ini','rb')
if f then
-- ダウンロードデータ識別とServiceIDとの対応を調べる
-- ロゴ識別とServiceIDとの対応を調べる
ddid=tonumber(f:read('*a'):upper():match(('\n%04X%04X=(%%d+)'):format(onid,sid)))
f:close()
if ddid then
Expand All @@ -36,7 +65,7 @@ if LOGO_DIR then
end
end
end
else
elseif not logo then
fname=('%04X%04X.png'):format(onid,sid)
f=edcb.io.open(DocumentToNativePath('img/logo/'..fname),'rb')
if not f then
Expand Down

0 comments on commit 695d6d3

Please sign in to comment.