BOOL CSetDlgAppBtn::OnInitDialog() { // TODO: ここに初期化を追加してください SetDlgItemText(m_hWnd, IDC_EDIT_VIEW_EXE, GetPrivateProfileToString( L"SET", L"ViewPath", L"", appIniPath.c_str() ).c_str()); SetDlgItemText(m_hWnd, IDC_EDIT_VIEW_OPT, GetPrivateProfileToString( L"SET", L"ViewOption", L"", appIniPath.c_str() ).c_str()); return TRUE; // return TRUE unless you set the focus to a control // 例外 : OCX プロパティ ページは必ず FALSE を返します。 }
CEpgDataCap_BonDlg::CEpgDataCap_BonDlg() : m_hWnd(NULL) , m_hKeyboardHook(NULL) { m_hIcon = (HICON)LoadImage( GetModuleHandle(NULL), MAKEINTRESOURCE( IDI_ICON_BLUE ), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); m_hIcon2 = (HICON)LoadImage( GetModuleHandle(NULL), MAKEINTRESOURCE( IDI_ICON_BLUE ), IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR); iconRed = (HICON)LoadImage( GetModuleHandle(NULL), MAKEINTRESOURCE( IDI_ICON_RED ), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); iconBlue = (HICON)LoadImage( GetModuleHandle(NULL), MAKEINTRESOURCE( IDI_ICON_BLUE ), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); iconGreen = (HICON)LoadImage( GetModuleHandle(NULL), MAKEINTRESOURCE( IDI_ICON_GREEN ), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); iconGray = (HICON)LoadImage( GetModuleHandle(NULL), MAKEINTRESOURCE( IDI_ICON_GRAY ), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); taskbarCreated = RegisterWindowMessage(L"TaskbarCreated"); wstring strPath = L""; GetModuleIniPath(strPath); this->moduleIniPath = strPath.c_str(); GetCommonIniPath(strPath); this->commonIniPath = strPath.c_str(); this->initONID = GetPrivateProfileInt( L"Set", L"LastONID", -1, this->moduleIniPath.c_str() ); this->initTSID = GetPrivateProfileInt( L"Set", L"LastTSID", -1, this->moduleIniPath.c_str() ); this->initSID = GetPrivateProfileInt( L"Set", L"LastSID", -1, this->moduleIniPath.c_str() ); this->iniBonDriver = GetPrivateProfileToString( L"Set", L"LastBon", L"", this->moduleIniPath.c_str() ); iniView = FALSE; iniNetwork = TRUE; iniMin = FALSE; this->iniUDP = FALSE; this->iniTCP = FALSE; this->minTask = GetPrivateProfileInt( L"Set", L"MinTask", 0, this->moduleIniPath.c_str() ); this->openLastCh = GetPrivateProfileInt( L"Set", L"OpenLast", 1, this->moduleIniPath.c_str() ); if( this->openLastCh == 0 ){ if( GetPrivateProfileInt( L"Set", L"OpenFix", 0, this->moduleIniPath.c_str() ) == 1){ this->initONID = GetPrivateProfileInt( L"Set", L"FixONID", -1, this->moduleIniPath.c_str() ); this->initTSID = GetPrivateProfileInt( L"Set", L"FixTSID", -1, this->moduleIniPath.c_str() ); this->initSID = GetPrivateProfileInt( L"Set", L"FixSID", -1, this->moduleIniPath.c_str() ); this->iniBonDriver = GetPrivateProfileToString( L"Set", L"FixBon", L"", this->moduleIniPath.c_str() ); }else{ this->initONID = -1; this->initTSID = -1; this->initSID = -1; this->iniBonDriver = L""; } } this->initOpenWait = 0; this->initChgWait = 0; }
void CTunerBankCtrl::ReloadSetting() { //モジュールini以外のパラメータは必要なときにその場で取得する wstring iniPath; GetModuleIniPath(iniPath); //録画開始のちょうどn分前だと起動と他チューナ録画開始が若干重なりやすくなるので僅かにずらす this->recWakeTime = ((__int64)GetPrivateProfileInt(L"SET", L"RecAppWakeTime", 2, iniPath.c_str()) * 60 - 3) * I64_1SEC; this->recWakeTime = max(this->recWakeTime, READY_MARGIN * I64_1SEC); this->recMinWake = GetPrivateProfileInt(L"SET", L"RecMinWake", 1, iniPath.c_str()) != 0; this->recView = GetPrivateProfileInt(L"SET", L"RecView", 1, iniPath.c_str()) != 0; this->recNW = GetPrivateProfileInt(L"SET", L"RecNW", 0, iniPath.c_str()) != 0; this->backPriority = GetPrivateProfileInt(L"SET", L"BackPriority", 1, iniPath.c_str()) != 0; this->saveProgramInfo = GetPrivateProfileInt(L"SET", L"PgInfoLog", 0, iniPath.c_str()) != 0; this->saveErrLog = GetPrivateProfileInt(L"SET", L"DropLog", 0, iniPath.c_str()) != 0; this->recOverWrite = GetPrivateProfileInt(L"SET", L"RecOverWrite", 0, iniPath.c_str()) != 0; int pr = GetPrivateProfileInt(L"SET", L"ProcessPriority", 3, iniPath.c_str()); this->processPriority = pr == 0 ? REALTIME_PRIORITY_CLASS : pr == 1 ? HIGH_PRIORITY_CLASS : pr == 2 ? ABOVE_NORMAL_PRIORITY_CLASS : pr == 3 ? NORMAL_PRIORITY_CLASS : pr == 4 ? BELOW_NORMAL_PRIORITY_CLASS : IDLE_PRIORITY_CLASS; this->keepDisk = GetPrivateProfileInt(L"SET", L"KeepDisk", 1, iniPath.c_str()) != 0; this->recNameNoChkYen = GetPrivateProfileInt(L"SET", L"NoChkYen", 0, iniPath.c_str()) != 0; this->recNamePlugInFileName.clear(); if( GetPrivateProfileInt(L"SET", L"RecNamePlugIn", 0, iniPath.c_str()) != 0 ){ this->recNamePlugInFileName = GetPrivateProfileToString(L"SET", L"RecNamePlugInFile", L"RecName_Macro.dll", iniPath.c_str()); } }
void CTunerBankCtrl::SaveProgramInfo(LPCWSTR recPath, const EPGDB_EVENT_INFO& info, bool append) const { wstring iniCommonPath; GetCommonIniPath(iniCommonPath); wstring infoFolder = GetPrivateProfileToString(L"SET", L"RecInfoFolder", L"", iniCommonPath.c_str()); ChkFolderPath(infoFolder); wstring savePath; if( infoFolder.empty() ){ savePath = recPath; }else{ GetFileName(recPath, savePath); savePath = infoFolder + L"\\" + savePath; } savePath += L".program.txt"; wstring serviceName; for( size_t i = 0; i < this->chList.size(); i++ ){ if( this->chList[i].originalNetworkID == info.original_network_id && this->chList[i].transportStreamID == info.transport_stream_id && this->chList[i].serviceID == info.service_id ){ serviceName = this->chList[i].serviceName; break; } } wstring outTextW; _ConvertEpgInfoText2(&info, outTextW, serviceName); string outText; WtoA(outTextW, outText); HANDLE hFile = _CreateDirectoryAndFile(savePath.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, NULL, append ? OPEN_ALWAYS : CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if( hFile != INVALID_HANDLE_VALUE ){ if( append ){ SetFilePointer(hFile, 0, NULL, FILE_END); outText = "\r\n-----------------------\r\n" + outText; } DWORD dwWrite; WriteFile(hFile, outText.c_str(), (DWORD)outText.size(), &dwWrite, NULL); CloseHandle(hFile); } }
CWriteMain::CWriteMain(void) { this->file = INVALID_HANDLE_VALUE; this->writeBuffSize = 0; this->teeFile = INVALID_HANDLE_VALUE; this->teeThread = NULL; WCHAR dllPath[MAX_PATH]; DWORD ret = GetModuleFileName(g_instance, dllPath, MAX_PATH); if( ret && ret < MAX_PATH ){ wstring iniPath = wstring(dllPath) + L".ini"; this->writeBuffSize = GetPrivateProfileInt(L"SET", L"Size", 770048, iniPath.c_str()); this->writeBuff.reserve(this->writeBuffSize); this->teeCmd = GetPrivateProfileToString(L"SET", L"TeeCmd", L"", iniPath.c_str()); if( this->teeCmd.empty() == false ){ this->teeBuff.resize(GetPrivateProfileInt(L"SET", L"TeeSize", 770048, iniPath.c_str())); this->teeBuff.resize(max(this->teeBuff.size(), 1)); this->teeDelay = GetPrivateProfileInt(L"SET", L"TeeDelay", 0, iniPath.c_str()); } } InitializeCriticalSection(&this->wroteLock); }
BOOL CSyoboiCalUtil::SendReserve(const vector<RESERVE_DATA>* reserveList, const vector<TUNER_RESERVE_INFO>* tunerList) { if( reserveList == NULL || tunerList == NULL ){ return FALSE; } if( reserveList->size() == 0 ){ return FALSE; } wstring iniAppPath = L""; GetModuleIniPath(iniAppPath); if( GetPrivateProfileInt(L"SYOBOI", L"use", 0, iniAppPath.c_str()) == 0 ){ return FALSE; } _OutputDebugString(L"★SyoboiCalUtil:SendReserve"); wstring textPath; GetModuleFolderPath(textPath); textPath += L"\\SyoboiCh.txt"; CParseServiceChgText srvChg; srvChg.ParseText(textPath.c_str()); wstring proxyServerName; wstring proxyUserName; wstring proxyPassword; if( GetPrivateProfileInt(L"SYOBOI", L"useProxy", 0, iniAppPath.c_str()) != 0 ){ proxyServerName = GetPrivateProfileToString(L"SYOBOI", L"ProxyServer", L"", iniAppPath.c_str()); proxyUserName = GetPrivateProfileToString(L"SYOBOI", L"ProxyID", L"", iniAppPath.c_str()); proxyPassword = GetPrivateProfileToString(L"SYOBOI", L"ProxyPWD", L"", iniAppPath.c_str()); } wstring id=GetPrivateProfileToString(L"SYOBOI", L"userID", L"", iniAppPath.c_str()); wstring pass=GetPrivateProfileToString(L"SYOBOI", L"PWD", L"", iniAppPath.c_str()); int slot = GetPrivateProfileInt(L"SYOBOI", L"slot", 0, iniAppPath.c_str()); wstring devcolors=GetPrivateProfileToString(L"SYOBOI", L"devcolors", L"", iniAppPath.c_str()); wstring epgurl=GetPrivateProfileToString(L"SYOBOI", L"epgurl", L"", iniAppPath.c_str()); if( id.size() == 0 ){ _OutputDebugString(L"★SyoboiCalUtil:NoUserID"); return FALSE; } //Authorization wstring auth = L""; auth = id; auth += L":"; auth += pass; string authA; WtoA(auth, authA); DWORD destSize = 0; Base64Enc(authA.c_str(), (DWORD)authA.size(), NULL, &destSize); vector<WCHAR> base64(destSize + 1, L'\0'); Base64Enc(authA.c_str(), (DWORD)authA.size(), &base64.front(), &destSize); //無駄なCRLFが混じることがあるため std::replace(base64.begin(), base64.end(), L'\r', L'\0'); std::replace(base64.begin(), base64.end(), L'\n', L'\0'); wstring authHead = L""; Format(authHead, L"Authorization: Basic %s\r\nContent-type: application/x-www-form-urlencoded\r\n", &base64.front()); //data wstring dataParam; wstring param; map<DWORD, wstring> tunerMap; for( size_t i=0; i<tunerList->size(); i++ ){ for( size_t j=0; j<(*tunerList)[i].reserveList.size(); j++ ){ tunerMap.insert(pair<DWORD, wstring>((*tunerList)[i].reserveList[j], (*tunerList)[i].tunerName)); } } map<DWORD, wstring>::iterator itrTuner; DWORD dataCount = 0; for(size_t i=0; i<reserveList->size(); i++ ){ if( dataCount>=200 ){ break; } const RESERVE_DATA* info = &(*reserveList)[i]; if( info->recSetting.recMode == RECMODE_NO || info->recSetting.recMode == RECMODE_VIEW ){ continue; } wstring device=L""; itrTuner = tunerMap.find(info->reserveID); if( itrTuner != tunerMap.end() ){ device = itrTuner->second; } wstring stationName = info->stationName; srvChg.ChgText(stationName); __int64 startTime = GetTimeStamp(info->startTime); Format(param, L"%I64d\t%I64d\t%s\t%s\t%s\t\t0\t%d\n", startTime, startTime+info->durationSecond, device.c_str(), info->title.c_str(), stationName.c_str(), info->reserveID ); dataParam+=param; } if(dataParam.size() == 0 ){ _OutputDebugString(L"★SyoboiCalUtil:NoReserve"); return FALSE; } string utf8; UrlEncodeUTF8(dataParam.c_str(), (DWORD)dataParam.size(), utf8); string data; Format(data, "slot=%d&data=%s",slot, utf8.c_str()); if( devcolors.size() > 0){ utf8 = ""; UrlEncodeUTF8(devcolors.c_str(), (DWORD)devcolors.size(), utf8); data += "&devcolors="; data += utf8; } if( epgurl.size() > 0){ utf8 = ""; UrlEncodeUTF8(epgurl.c_str(), (DWORD)epgurl.size(), utf8); data += "&epgurl="; data += utf8; } vector<char> dataBuff(data.begin(), data.end()); //URLの分解 URL_COMPONENTS stURL = {}; stURL.dwStructSize = sizeof(stURL); stURL.dwSchemeLength = (DWORD)-1; stURL.dwHostNameLength = (DWORD)-1; stURL.dwUrlPathLength = (DWORD)-1; stURL.dwExtraInfoLength = (DWORD)-1; if( WinHttpCrackUrl(SYOBOI_UP_URL, 0, 0, &stURL) == FALSE || stURL.dwHostNameLength == 0 ){ return FALSE; } wstring host(stURL.lpszHostName, stURL.dwHostNameLength); wstring sendUrl(stURL.lpszUrlPath, stURL.dwUrlPathLength + stURL.dwExtraInfoLength); HINTERNET session; if( proxyServerName.empty() ){ session = WinHttpOpen(L"EpgTimerSrv", WINHTTP_ACCESS_TYPE_NO_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0); }else{ session = WinHttpOpen(L"EpgTimerSrv", WINHTTP_ACCESS_TYPE_NAMED_PROXY, proxyServerName.c_str(), WINHTTP_NO_PROXY_BYPASS, 0); } if( session == NULL ){ return FALSE; } LPCWSTR result = L"1"; HINTERNET connect = NULL; HINTERNET request = NULL; if( WinHttpSetTimeouts(session, 15000, 15000, 15000, 15000) == FALSE ){ result = L"0 SetTimeouts"; goto EXIT; } //コネクションオープン connect = WinHttpConnect(session, host.c_str(), stURL.nPort, 0); if( connect == NULL ){ result = L"0 Connect"; goto EXIT; } //リクエストオープン request = WinHttpOpenRequest(connect, L"POST", sendUrl.c_str(), NULL, WINHTTP_NO_REFERER, WINHTTP_DEFAULT_ACCEPT_TYPES, stURL.nPort == INTERNET_DEFAULT_HTTPS_PORT ? WINHTTP_FLAG_SECURE : 0); if( request == NULL ){ result = L"0 OpenRequest"; goto EXIT; } if( proxyServerName.empty() == false ){ //ProxyのIDかパスワードがあったらセット if( proxyUserName.empty() == false || proxyPassword.empty() == false ){ if( WinHttpSetCredentials(request, WINHTTP_AUTH_TARGET_PROXY, WINHTTP_AUTH_SCHEME_BASIC, proxyUserName.c_str(), proxyPassword.c_str(), NULL) == FALSE ){ result = L"0 SetCredentials"; goto EXIT; } } } if( WinHttpSendRequest(request, authHead.c_str(), (DWORD)-1, &dataBuff.front(), (DWORD)dataBuff.size(), (DWORD)dataBuff.size(), 0) == FALSE ){ result = L"0 SendRequest"; goto EXIT; } if( WinHttpReceiveResponse(request, NULL) == FALSE ){ result = L"0 ReceiveResponse"; goto EXIT; } //HTTPのステータスコード確認 DWORD statusCode; DWORD statusCodeSize = sizeof(statusCode); if( WinHttpQueryHeaders(request, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, WINHTTP_HEADER_NAME_BY_INDEX, &statusCode, &statusCodeSize, WINHTTP_NO_HEADER_INDEX) == FALSE ){ statusCode = 0; } if( statusCode != 200 && statusCode != 201 ){ result = L"0 StatusNotOK"; goto EXIT; } EXIT: if( request != NULL ){ WinHttpCloseHandle(request); } if( connect != NULL ){ WinHttpCloseHandle(connect); } if( session != NULL ){ WinHttpCloseHandle(session); } _OutputDebugString(L"★SyoboiCalUtil:SendRequest res:%s", result); if( result[0] != L'1' ){ return FALSE; } return TRUE; }
bool CTunerBankCtrl::RecStart(const TUNER_RESERVE& reserve, __int64 now) const { if( this->hTunerProcess == NULL ){ return false; } if( reserve.recMode == RECMODE_VIEW ){ return true; } CSendCtrlCmd ctrlCmd; ctrlCmd.SetPipeSetting(CMD2_VIEW_CTRL_WAIT_CONNECT, CMD2_VIEW_CTRL_PIPE, this->tunerPid); bool isMainCtrl = true; for( int i = 0; i < 2; i++ ){ if( reserve.ctrlID[i] != 0 ){ SET_CTRL_REC_PARAM param; param.ctrlID = reserve.ctrlID[i]; //saveFolder[].recFileNameが空でない限りこのフィールドが利用されることはない param.fileName = L"padding.ts"; //同時出力用ファイル名 param.saveFolder = i == 0 ? reserve.recFolder : reserve.partialRecFolder; if( param.saveFolder.empty() ){ param.saveFolder.resize(1); wstring commonIniPath; GetCommonIniPath(commonIniPath); GetRecFolderPath(param.saveFolder[0].recFolder); param.saveFolder[0].writePlugIn = GetPrivateProfileToString(L"SET", L"RecWritePlugIn0", L"", commonIniPath.c_str()); param.saveFolder[0].recNamePlugIn = this->recNamePlugInFileName; }else{ for( size_t j = 0; j < param.saveFolder.size(); j++ ){ if( CompareNoCase(param.saveFolder[j].recFolder, L"!Default") == 0 ){ //注意: この置換は原作にはない GetRecFolderPath(param.saveFolder[j].recFolder); } if( param.saveFolder[j].recNamePlugIn.empty() ){ param.saveFolder[j].recNamePlugIn = this->recNamePlugInFileName; } } } //recNamePlugInを展開して実ファイル名をセット for( size_t j = 0; j < param.saveFolder.size(); j++ ){ param.saveFolder[j].recFileName.clear(); if( param.saveFolder[j].recNamePlugIn.empty() == false ){ WORD sid = reserve.sid; WORD eid = reserve.eid; wstring stationName = reserve.stationName; if( i != 0 ){ FindPartialService(reserve.onid, reserve.tsid, reserve.sid, &sid, &stationName); eid = 0xFFFF; } wstring plugInPath; GetModuleFolderPath(plugInPath); plugInPath += L"\\RecName\\"; { PLUGIN_RESERVE_INFO info; ConvertSystemTime(reserve.startTime, &info.startTime); info.durationSec = reserve.durationSecond; wcscpy_s(info.eventName, reserve.title.c_str()); info.ONID = reserve.onid; info.TSID = reserve.tsid; info.SID = sid; info.EventID = eid; wcscpy_s(info.serviceName, stationName.c_str()); wcscpy_s(info.bonDriverName, this->bonFileName.c_str()); info.bonDriverID = this->tunerID >> 16; info.tunerID = this->tunerID & 0xFFFF; EPG_EVENT_INFO* epgInfo = NULL; if( info.EventID != 0xFFFF ){ EPGDB_EVENT_INFO epgDBInfo; if( this->epgDBManager.SearchEpg(info.ONID, info.TSID, info.SID, info.EventID, &epgDBInfo) != FALSE ){ epgInfo = new EPG_EVENT_INFO; CopyEpgInfo(epgInfo, &epgDBInfo); } } info.reserveID = reserve.reserveID; info.epgInfo = epgInfo; info.sizeOfStruct = 0; WCHAR name[512]; DWORD size = 512; if( CReNamePlugInUtil::ConvertRecName3(&info, param.saveFolder[j].recNamePlugIn.c_str(), plugInPath.c_str(), name, &size) ){ param.saveFolder[j].recFileName = name; CheckFileName(param.saveFolder[j].recFileName, this->recNameNoChkYen); } delete epgInfo; } param.saveFolder[j].recNamePlugIn.clear(); } //実ファイル名は空にしない if( param.saveFolder[j].recFileName.empty() ){ SYSTEMTIME st; ConvertSystemTime(max(reserve.startTime, now), &st); Format(param.saveFolder[j].recFileName, L"%04d%02d%02d%02d%02d%02X%02X%02d-%s.ts", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, this->tunerID >> 16, this->tunerID & 0xFFFF, param.ctrlID, reserve.title.c_str()); CheckFileName(param.saveFolder[j].recFileName); } }