Example #1
0
DWORD CRestApiManager::GetReserveAddResponse(BOOL err, HTTP_STREAM* sendParam)
{
	DWORD ret = NO_ERR;

	vector<EPGDB_SERVICE_INFO> list;
	wstring xml = L"";
	string utf8 = "";
	if( err == TRUE ){
		xml += L"<?xml version=\"1.0\" encoding=\"UTF-8\" ?><entry>";
		xml += L"<success>予約の追加に成功しました</success>";
		xml += L"</entry>";
	}else{
		xml += L"<?xml version=\"1.0\" encoding=\"UTF-8\" ?><entry>";
		xml += L"<err>予約の追加に失敗しました</err>";
		xml += L"</entry>";
	}

	WtoUTF8(xml, utf8);

	sendParam->dataSize = (DWORD)utf8.size();
	sendParam->data = new BYTE[sendParam->dataSize];
	memcpy(sendParam->data, utf8.c_str(), sendParam->dataSize);
	if( sendParam->dataSize > 0 ){
		Format(sendParam->httpHeader, "HTTP/1.0 200 OK\r\nContent-Type: text/xml\r\nContent-Length: %d\r\nConnection: close\r\n\r\n", sendParam->dataSize);
	}else{
		sendParam->httpHeader = "HTTP/1.0 400 Bad Request\r\nConnection: close\r\n\r\n";
	}

	return ret;
}
Example #2
0
DWORD CRestApiManager::GetEnumService(string param, HTTP_STREAM* sendParam, CEpgDBManager* epgDB)
{
	DWORD ret = NO_ERR;

	vector<EPGDB_SERVICE_INFO> list;
	wstring xml = L"";
	string utf8 = "";
	if( epgDB->GetServiceList(&list) == TRUE ){
		wstring buff = L"";
		xml += L"<?xml version=\"1.0\" encoding=\"UTF-8\" ?><entry>";
		Format(buff, L"<total>%d</total><index>0</index><count>%d</count>", list.size(), list.size());
		xml += buff;
		xml += L"<items>";
		wstring serviceinfo = L"";
		for( size_t i=0; i<list.size(); i++ ){
			serviceinfo += L"<serviceinfo>";
			Format(buff, L"<ONID>%d</ONID>", list[i].ONID);
			serviceinfo += buff;
			Format(buff, L"<TSID>%d</TSID>", list[i].TSID);
			serviceinfo += buff;
			Format(buff, L"<SID>%d</SID>", list[i].SID);
			serviceinfo += buff;
			Format(buff, L"<service_type>%d</service_type>", list[i].service_type);
			serviceinfo += buff;
			Format(buff, L"<partialReceptionFlag>%d</partialReceptionFlag>", list[i].partialReceptionFlag);
			serviceinfo += buff;
			Format(buff, L"<service_provider_name>%s</service_provider_name>", list[i].service_provider_name.c_str());
			serviceinfo += buff;
			Format(buff, L"<service_name>%s</service_name>", list[i].service_name.c_str());
			serviceinfo += buff;
			Format(buff, L"<network_name>%s</network_name>", list[i].network_name.c_str());
			serviceinfo += buff;
			Format(buff, L"<ts_name>%s</ts_name>", list[i].ts_name.c_str());
			serviceinfo += buff;
			Format(buff, L"<remote_control_key_id>%d</remote_control_key_id>", list[i].remote_control_key_id);
			serviceinfo += buff;
			serviceinfo += L"</serviceinfo>";
		}
		xml += serviceinfo;
		xml += L"</items>";
		xml += L"</entry>";
	}else{
		xml += L"<?xml version=\"1.0\" encoding=\"UTF-8\" ?><entry>";
		xml += L"<err>EPGデータを読み込み中、または存在しません</err>";
		xml += L"</entry>";
	}

	WtoUTF8(xml, utf8);

	sendParam->dataSize = (DWORD)utf8.size();
	sendParam->data = new BYTE[sendParam->dataSize];
	memcpy(sendParam->data, utf8.c_str(), sendParam->dataSize);
	if( sendParam->dataSize > 0 ){
		Format(sendParam->httpHeader, "HTTP/1.0 200 OK\r\nContent-Type: text/xml\r\nContent-Length: %d\r\nConnection: close\r\n\r\n", sendParam->dataSize);
	}else{
		sendParam->httpHeader = "HTTP/1.0 400 Bad Request\r\nConnection: close\r\n\r\n";
	}

	return ret;
}
Example #3
0
BOOL CSyoboiCalUtil::UrlEncodeUTF8(LPCWSTR src, DWORD srcSize, string& dest)
{
	if( src == NULL || srcSize == 0 ){
		return FALSE;
	}

	WtoUTF8(src, dest);

	for( size_t i=0; i<dest.size(); ){
		if( ( dest[i] >= 'A' && dest[i] <= 'Z' ) ||
			( dest[i] >= 'a' && dest[i] <= 'z' ) ||
			( dest[i] >= '0' && dest[i] <= '9' ) 
			)
		{
			i++;
		}else{
			char cEnc[4]="";
			sprintf_s( cEnc, "%%%02X", (BYTE)dest[i] );
			dest.replace(i, 1, cEnc, 3);
			i += 3;
		}
	}

	return TRUE;
}
Example #4
0
/*
int CSOAPUtil::EscapeXmlString(wstring& src)
{
	Replace(src, L"&", L"&amp;");
	Replace(src, L"<", L"&lt;");
	Replace(src, L">", L"&gt;");
	Replace(src, L"\"", L"&quot;");
	Replace(src, L"'", L"&apos;");

	return 1;
}
*/
int CSOAPUtil::CreateSOAPResponseBody(char* actionXmlns, char* actionName, vector<SOAP_RESPONSE_ARG>* argumentList, char* xml, int* xmlSize)
{
    string createXml = "";
    string buff = "";
    wstring buffW = L"";
    string buffUTF8 = "";

    createXml = soapStart;

    Format(buff, soapActionTag, actionName, actionXmlns);
    createXml+=buff;

    for( size_t i=0; i<argumentList->size(); i++ ) {
        AtoW((*argumentList)[i].val, buffW);
        EscapeXmlString(buffW);
        WtoUTF8(buffW, buffUTF8);
        Format(buff, soapArgumentTag, (*argumentList)[i].name.c_str(), buffUTF8.c_str(), (*argumentList)[i].name.c_str());
        createXml+=buff;
    }

    Format(buff, soapActionTagEnd, actionName);
    createXml+=buff;

    createXml += soapEnd;

    if( *xmlSize < (int)createXml.size() ) {
        *xmlSize = (int)createXml.size()+1;
        return 2;
    }

    if( xml != NULL ) {
        strcpy_s(xml, *xmlSize, createXml.c_str());
    }
    *xmlSize = (int)createXml.size()+1;

    return 1;
}
Example #5
0
DWORD CRestApiManager::GetSearchEvent(string param, HTTP_STREAM* sendParam, CEpgDBManager* epgDB)
{
	DWORD ret = NO_ERR;

	map<string,string> paramMap;
	while(param.size()>0){
		string buff;
		Separate(param, "&", buff, param);
		if(buff.size()>0){
			string key;
			string val;
			Separate(buff, "=", key, val);
			paramMap.insert(pair<string,string>(key, val));
		}
	}

	map<string,string>::iterator itr;
	WORD network = 0xFFFF;
	itr = paramMap.find("network");
	if( itr != paramMap.end() ){
		network = (WORD)atoi(itr->second.c_str());
	}
	WORD days = 0;
	itr = paramMap.find("days");
	if( itr != paramMap.end() ){
		days = (WORD)atoi(itr->second.c_str());
	}

	wstring andkey;
	itr = paramMap.find("andkey");
	if( itr != paramMap.end() ){
		string utf8;
		UrlDecode(itr->second.c_str(), (DWORD)itr->second.size(), utf8);
		UTF8toW(utf8, andkey);
	}
	wstring notkey;
	itr = paramMap.find("notkey");
	if( itr != paramMap.end() ){
		string utf8;
		UrlDecode(itr->second.c_str(), (DWORD)itr->second.size(), utf8);
		UTF8toW(utf8, notkey);
	}
	vector<DWORD> genru;
	itr = paramMap.find("genru");
	if( itr != paramMap.end() ){
		string val = itr->second;
		string id;
		while(val.size() > 0 ){
			Separate(val, "-", id, val);
			genru.push_back((DWORD)atoi(id.c_str()));
		}
	}

	DWORD index = 0;
	itr = paramMap.find("index");
	if( itr != paramMap.end() ){
		index = (DWORD)atoi(itr->second.c_str());
	}
	DWORD count = 200;
	itr = paramMap.find("count");
	if( itr != paramMap.end() ){
		count = (DWORD)atoi(itr->second.c_str());
	}
	WORD basicOnly = 1;
	itr = paramMap.find("basic");
	if( itr != paramMap.end() ){
		basicOnly = (WORD)atoi(itr->second.c_str());
	}

	//検索条件
	EPGDB_SEARCH_KEY_INFO searchKey;
	searchKey.andKey = andkey;
	searchKey.notKey = notkey;
	for( size_t i=0; i<genru.size(); i++){
		EPGDB_CONTENT_DATA item;
		item.content_nibble_level_1 = (BYTE)(genru[i]>>8);
		item.content_nibble_level_2 = (BYTE)(genru[i]&0x00FF);
		searchKey.contentList.push_back(item);
	}
	//対象サービス
	vector<EPGDB_SERVICE_INFO> list;
	if( epgDB->GetServiceList(&list) == TRUE ){
		if( network != 0xFFFF ){
			for( size_t i=0; i<list.size(); i++ ){
				__int64 key = _Create64Key(list[i].ONID,list[i].TSID, list[i].SID);

				if( 0x7880 <= list[i].ONID && list[i].ONID<= 0x7FE8 ){
					//地デジ
					if( (network & 0x0001) > 0 ){
						searchKey.serviceList.push_back(key);
					}
				}else
				if( list[i].ONID == 0x0004 ){
					//BS
					if( (network & 0x0002) > 0 ){
						searchKey.serviceList.push_back(key);
					}
				}else
				if( list[i].ONID == 0x0006 || list[i].ONID == 0x0007 ){
					//CS
					if( (network & 0x0004) > 0 ){
						searchKey.serviceList.push_back(key);
					}
				}else{
					//その他
					if( (network & 0x0008) > 0 ){
						searchKey.serviceList.push_back(key);
					}
				}
			}
		}
	}

	//対象期間
	__int64 chkTime = 0;
	if( days > 0 ){
		SYSTEMTIME now;
		GetLocalTime(&now);
		now.wHour = 0;
		now.wMinute = 0;
		now.wSecond = 0;
		now.wMilliseconds = 0;

		chkTime = ConvertI64Time(now);
		chkTime += days*(29*60*60*I64_1SEC);
	}

	vector<EPGDB_SEARCH_KEY_INFO> keyList;
	keyList.push_back(searchKey);
	vector<EPGDB_EVENT_INFO*> resultList;
	wstring xml = L"";
	string utf8 = "";
	epgDB->SearchEpg(&keyList, &resultList);
	map<__int64, __int64> addID;
	map<__int64, __int64>::iterator itrAdd;
	if ( resultList.size() > 0 ){
		xml += L"<?xml version=\"1.0\" encoding=\"UTF-8\" ?><entry>";
		DWORD total = 0;
		DWORD findCount = 0;

		wstring serviceinfo = L"<items>";
		wstring buff;
		for( size_t i = 0; i<resultList.size(); i++){
			if( days > 0 ){
				if( chkTime < ConvertI64Time(resultList[i]->start_time)){
					continue;
				}
			}
			if( resultList[i]->eventGroupInfo != NULL ){
				BOOL find = FALSE;
				for( size_t j=0; j<resultList[i]->eventGroupInfo->eventDataList.size(); j++ ){
					__int64 evid = _Create64Key2(resultList[i]->eventGroupInfo->eventDataList[j].original_network_id,
						resultList[i]->eventGroupInfo->eventDataList[j].transport_stream_id,
						resultList[i]->eventGroupInfo->eventDataList[j].service_id,
						resultList[i]->eventGroupInfo->eventDataList[j].event_id);
					itrAdd = addID.find(evid);
					if( itrAdd != addID.end() ){
						find = TRUE;
					}
				}
				if( find == TRUE ){
					continue;
				}
			}
			__int64 evid = _Create64Key2(resultList[i]->original_network_id,
				resultList[i]->transport_stream_id,
				resultList[i]->service_id,
				resultList[i]->event_id);
			addID.insert(pair<__int64, __int64>(evid,evid));
			if( total < index ){
				total++;
				continue;
			}
			if( index + count <= total ){
				total++;
				continue;
			}
			total++;
			findCount++;

			EPGDB_EVENT_INFO* eventInfo = resultList[i];

			serviceinfo += L"<eventinfo>";
			Format(buff, L"<ONID>%d</ONID>", eventInfo->original_network_id);
			serviceinfo += buff;
			Format(buff, L"<TSID>%d</TSID>", eventInfo->transport_stream_id);
			serviceinfo += buff;
			Format(buff, L"<SID>%d</SID>", eventInfo->service_id);
			serviceinfo += buff;
			Format(buff, L"<eventID>%d</eventID>", eventInfo->event_id);
			serviceinfo += buff;
			if( eventInfo->StartTimeFlag == 1 ){
				Format(buff, L"<startDate>%04d/%02d/%02d</startDate>", eventInfo->start_time.wYear, eventInfo->start_time.wMonth, eventInfo->start_time.wDay);
				serviceinfo += buff;
				Format(buff, L"<startTime>%02d:%02d:%02d</startTime>", eventInfo->start_time.wHour, eventInfo->start_time.wMinute, eventInfo->start_time.wSecond);
				serviceinfo += buff;
				Format(buff, L"<startDayOfWeek>%d</startDayOfWeek>", eventInfo->start_time.wDayOfWeek);
				serviceinfo += buff;
			}
			if( eventInfo->DurationFlag == 1 ){
				Format(buff, L"<duration>%d</duration>", eventInfo->durationSec);
				serviceinfo += buff;
			}
			if( eventInfo->shortInfo != NULL ){
				wstring chk = eventInfo->shortInfo->event_name;
				CheckXMLChar(chk);
				Format(buff, L"<event_name>%s</event_name>", chk.c_str());
				serviceinfo += buff;

				chk = eventInfo->shortInfo->text_char;
				CheckXMLChar(chk);
				Format(buff, L"<event_text>%s</event_text>", chk.c_str());
				serviceinfo += buff;
			}
			if( eventInfo->contentInfo != NULL ){
				serviceinfo += L"";
				for( size_t k=0; k<eventInfo->contentInfo->nibbleList.size(); k++){
					wstring nibble = L"";
					Format(nibble,L"<contentInfo><nibble1>%d</nibble1><nibble2>%d</nibble2></contentInfo>", 
						eventInfo->contentInfo->nibbleList[k].content_nibble_level_1,
						eventInfo->contentInfo->nibbleList[k].content_nibble_level_2);
					serviceinfo += nibble;
				}
			}
			if( eventInfo->eventGroupInfo != NULL ){
				for( size_t k=0; k<eventInfo->eventGroupInfo->eventDataList.size(); k++){
					wstring group = L"";
					Format(group,L"<groupInfo><ONID>%d</ONID><TSID>%d</TSID><SID>%d</SID><eventID>%d</eventID></groupInfo>", 
						eventInfo->eventGroupInfo->eventDataList[k].original_network_id,
						eventInfo->eventGroupInfo->eventDataList[k].transport_stream_id,
						eventInfo->eventGroupInfo->eventDataList[k].service_id,
						eventInfo->eventGroupInfo->eventDataList[k].event_id
						);
					serviceinfo += group;
				}
			}

			Format(buff, L"<freeCAFlag>%d</freeCAFlag>", eventInfo->freeCAFlag);
			serviceinfo += buff;

			if( basicOnly == 0 ){
				if( eventInfo->extInfo != NULL ){
					wstring chk = eventInfo->extInfo->text_char;
					CheckXMLChar(chk);
					Format(buff, L"<event_ext_text>%s</event_ext_text>", chk.c_str());
					serviceinfo += buff;
				}
				if( eventInfo->componentInfo != NULL ){
					Format(buff, L"<videoInfo><stream_content>%d</stream_content><component_type>%d</component_type><component_tag>%d</component_tag><text>%s</text></videoInfo>", 
						eventInfo->componentInfo->stream_content,
						eventInfo->componentInfo->component_type,
						eventInfo->componentInfo->component_tag,
						eventInfo->componentInfo->text_char.c_str()
						);
					serviceinfo += buff;
				}
				if( eventInfo->audioInfo != NULL ){
					for( size_t k=0; k<eventInfo->audioInfo->componentList.size(); k++ ){
						Format(buff, L"<audioInfo><stream_content>%d</stream_content><component_type>%d</component_type><component_tag>%d</component_tag><stream_type>%d</stream_type><simulcast_group_tag>%d</simulcast_group_tag><ES_multi_lingual_flag>%d</ES_multi_lingual_flag><main_component_flag>%d</main_component_flag><quality_indicator>%d</quality_indicator><sampling_rate>%d</sampling_rate><text>%s</text></audioInfo>", 
							eventInfo->audioInfo->componentList[k].stream_content,
							eventInfo->audioInfo->componentList[k].component_type,
							eventInfo->audioInfo->componentList[k].component_tag,
							eventInfo->audioInfo->componentList[k].stream_type,
							eventInfo->audioInfo->componentList[k].simulcast_group_tag,
							eventInfo->audioInfo->componentList[k].ES_multi_lingual_flag,
							eventInfo->audioInfo->componentList[k].main_component_flag,
							eventInfo->audioInfo->componentList[k].quality_indicator,
							eventInfo->audioInfo->componentList[k].sampling_rate,
							eventInfo->audioInfo->componentList[k].text_char.c_str()
							);
						serviceinfo += buff;
					}
				}
				if( eventInfo->eventRelayInfo != NULL ){
					for( size_t k=0; k<eventInfo->eventRelayInfo->eventDataList.size(); k++){
						wstring group = L"";
						Format(group,L"<relayInfo><ONID>%d</ONID><TSID>%d</TSID><SID>%d</SID><eventID>%d</eventID></relayInfo>", 
							eventInfo->eventRelayInfo->eventDataList[k].original_network_id,
							eventInfo->eventRelayInfo->eventDataList[k].transport_stream_id,
							eventInfo->eventRelayInfo->eventDataList[k].service_id,
							eventInfo->eventRelayInfo->eventDataList[k].event_id
							);
						serviceinfo += group;
					}
				}
			}
			serviceinfo += L"</eventinfo>";
		}
		serviceinfo += L"</items>";

		Format(buff, L"<total>%d</total><index>%d</index><count>%d</count>", total, index, findCount);
		xml += buff;
		xml += serviceinfo;
		xml += L"</entry>";
	}else{
		xml += L"<?xml version=\"1.0\" encoding=\"UTF-8\" ?><entry>";
		xml += L"<err>EPGデータを読み込み中、または存在しません</err>";
		xml += L"</entry>";
	}

	WtoUTF8(xml, utf8);

	sendParam->dataSize = (DWORD)utf8.size();
	sendParam->data = new BYTE[sendParam->dataSize];
	memcpy(sendParam->data, utf8.c_str(), sendParam->dataSize);
	if( sendParam->dataSize > 0 ){
		Format(sendParam->httpHeader, "HTTP/1.0 200 OK\r\nContent-Type: text/xml\r\nContent-Length: %d\r\nConnection: close\r\n\r\n", sendParam->dataSize);
	}else{
		sendParam->httpHeader = "HTTP/1.0 400 Bad Request\r\nConnection: close\r\n\r\n";
	}

	return ret;
}
Example #6
0
DWORD CRestApiManager::GetEnumRecPresetInfo(string param, HTTP_STREAM* sendParam)
{
	DWORD ret = NO_ERR;

	wstring iniPath = L"";
	GetModuleIniPath(iniPath);
	WCHAR iniBuff[512]=L"";
	GetPrivateProfileString(L"SET", L"PresetID", L"", iniBuff, 512, iniPath.c_str());
	wstring parseBuff = iniBuff;
	vector<DWORD> idList;
	idList.push_back(0);
	do{
		wstring presetID =L"";
		Separate(parseBuff, L",", presetID, parseBuff);
		idList.push_back((DWORD)_wtoi(presetID.c_str()));
	}while(parseBuff.size()>0);


	wstring xml = L"";
	string utf8 = "";

	wstring buff = L"";
	xml += L"<?xml version=\"1.0\" encoding=\"UTF-8\" ?><entry>";
	Format(buff, L"<total>%d</total><index>0</index><count>%d</count>", idList.size(), idList.size());
	xml += buff;
	xml += L"<items>";
	wstring reserveinfo = L"";
	for( size_t i=0; i<idList.size(); i++ ){
		REC_SETTING_DATA recSetting;
		LoadRecSetData((WORD)idList[i], &recSetting);

		reserveinfo += L"<recpresetinfo>";

		if( idList[i] == 0 ){
			Format(buff, L"<id>%d</id>", idList[i]);
			reserveinfo += buff;
			reserveinfo += L"<name>デフォルト</name>";
		}else{
			wstring appName = L"";
			Format(appName, L"REC_DEF%d", idList[i]);
			ZeroMemory(iniBuff, sizeof(WCHAR)*512);
			GetPrivateProfileString(appName.c_str(), L"SetName", L"", iniBuff, 512, iniPath.c_str());

			Format(buff, L"<id>%d</id>", idList[i]);
			reserveinfo += buff;
			Format(buff, L"<name>%s</name>", iniBuff);
			reserveinfo += buff;
		}
		reserveinfo += L"<recsetting>";
		Format(buff, L"<recMode>%d</recMode>", recSetting.recMode);
		reserveinfo += buff;
		Format(buff, L"<priority>%d</priority>", recSetting.priority);
		reserveinfo += buff;
		Format(buff, L"<tuijyuuFlag>%d</tuijyuuFlag>", recSetting.tuijyuuFlag);
		reserveinfo += buff;
		Format(buff, L"<serviceMode>%d</serviceMode>", recSetting.serviceMode);
		reserveinfo += buff;
		Format(buff, L"<pittariFlag>%d</pittariFlag>", recSetting.pittariFlag);
		reserveinfo += buff;
		Format(buff, L"<batFilePath>%s</batFilePath>", recSetting.batFilePath.c_str());
		reserveinfo += buff;
		reserveinfo += L"<recFolderList>";
		for( size_t j=0; j<recSetting.recFolderList.size(); j++ ){
			reserveinfo += L"<recFolderInfo>";
			Format(buff, L"<recFolder>%s</recFolder>", recSetting.recFolderList[j].recFolder.c_str());
			reserveinfo += buff;
			Format(buff, L"<writePlugIn>%s</writePlugIn>", recSetting.recFolderList[j].writePlugIn.c_str());
			reserveinfo += buff;
			Format(buff, L"<recNamePlugIn>%s</recNamePlugIn>", recSetting.recFolderList[j].recNamePlugIn.c_str());
			reserveinfo += buff;
			reserveinfo += L"</recFolderInfo>";
		}
		reserveinfo += L"</recFolderList>";
		Format(buff, L"<suspendMode>%d</suspendMode>", recSetting.suspendMode);
		reserveinfo += buff;
		Format(buff, L"<rebootFlag>%d</rebootFlag>", recSetting.rebootFlag);
		reserveinfo += buff;
		Format(buff, L"<useMargineFlag>%d</useMargineFlag>", recSetting.useMargineFlag);
		reserveinfo += buff;
		Format(buff, L"<startMargine>%d</startMargine>", recSetting.startMargine);
		reserveinfo += buff;
		Format(buff, L"<endMargine>%d</endMargine>", recSetting.endMargine);
		reserveinfo += buff;
		Format(buff, L"<continueRecFlag>%d</continueRecFlag>", recSetting.continueRecFlag);
		reserveinfo += buff;
		Format(buff, L"<partialRecFlag>%d</partialRecFlag>", recSetting.partialRecFlag);
		reserveinfo += buff;
		Format(buff, L"<tunerID>%d</tunerID>", recSetting.tunerID);
		reserveinfo += buff;
		reserveinfo += L"<partialRecFolder>";
		for( size_t j=0; j<recSetting.partialRecFolder.size(); j++ ){
			reserveinfo += L"<recFolderInfo>";
			Format(buff, L"<recFolder>%s</recFolder>", recSetting.partialRecFolder[j].recFolder.c_str());
			reserveinfo += buff;
			Format(buff, L"<writePlugIn>%s</writePlugIn>", recSetting.partialRecFolder[j].writePlugIn.c_str());
			reserveinfo += buff;
			Format(buff, L"<recNamePlugIn>%s</recNamePlugIn>", recSetting.partialRecFolder[j].recNamePlugIn.c_str());
			reserveinfo += buff;
			reserveinfo += L"</recFolderInfo>";
		}
		reserveinfo += L"</partialRecFolder>";
		reserveinfo += L"</recsetting>";

		reserveinfo += L"</recpresetinfo>";
	}
	xml += reserveinfo;
	xml += L"</items>";
	xml += L"</entry>";

	WtoUTF8(xml, utf8);

	sendParam->dataSize = (DWORD)utf8.size();
	sendParam->data = new BYTE[sendParam->dataSize];
	memcpy(sendParam->data, utf8.c_str(), sendParam->dataSize);
	if( sendParam->dataSize > 0 ){
		Format(sendParam->httpHeader, "HTTP/1.0 200 OK\r\nContent-Type: text/xml\r\nContent-Length: %d\r\nConnection: close\r\n\r\n", sendParam->dataSize);
	}else{
		sendParam->httpHeader = "HTTP/1.0 400 Bad Request\r\nConnection: close\r\n\r\n";
	}

	return ret;
}
Example #7
0
DWORD CRestApiManager::GetEnumReserveInfo(string param, HTTP_STREAM* sendParam, vector<RESERVE_DATA*>* list)
{
	DWORD ret = NO_ERR;

	wstring xml = L"";
	string utf8 = "";

	wstring buff = L"";
	xml += L"<?xml version=\"1.0\" encoding=\"UTF-8\" ?><entry>";
	Format(buff, L"<total>%d</total><index>0</index><count>%d</count>", list->size(), list->size());
	xml += buff;
	xml += L"<items>";
	wstring reserveinfo = L"";
	for( size_t i=0; i<list->size(); i++ ){
		reserveinfo += L"<reserveinfo>";
		Format(buff, L"<ID>%d</ID>", (*list)[i]->reserveID);
		reserveinfo += buff;
		Format(buff, L"<title>%s</title>", (*list)[i]->title.c_str());
		reserveinfo += buff;
		Format(buff, L"<startDate>%d/%d/%d</startDate>", (*list)[i]->startTime.wYear, (*list)[i]->startTime.wMonth, (*list)[i]->startTime.wDay);
		reserveinfo += buff;
		Format(buff, L"<startTime>%d:%d:%d</startTime>", (*list)[i]->startTime.wHour, (*list)[i]->startTime.wMinute, (*list)[i]->startTime.wSecond);
		reserveinfo += buff;
		Format(buff, L"<startDayOfWeek>%d</startDayOfWeek>", (*list)[i]->startTime.wDayOfWeek);
		reserveinfo += buff;
		Format(buff, L"<duration>%d</duration>", (*list)[i]->durationSecond);
		reserveinfo += buff;
		Format(buff, L"<service_name>%s</service_name>", (*list)[i]->stationName.c_str());
		reserveinfo += buff;
		Format(buff, L"<ONID>%d</ONID>", (*list)[i]->originalNetworkID);
		reserveinfo += buff;
		Format(buff, L"<TSID>%d</TSID>", (*list)[i]->transportStreamID);
		reserveinfo += buff;
		Format(buff, L"<SID>%d</SID>", (*list)[i]->serviceID);
		reserveinfo += buff;
		Format(buff, L"<eventID>%d</eventID>", (*list)[i]->eventID);
		reserveinfo += buff;
		Format(buff, L"<comment>%s</comment>", (*list)[i]->comment.c_str());
		reserveinfo += buff;
		Format(buff, L"<overlapMode>%d</overlapMode>", (*list)[i]->overlapMode);
		reserveinfo += buff;

		reserveinfo += L"<recsetting>";
		Format(buff, L"<recMode>%d</recMode>", (*list)[i]->recSetting.recMode);
		reserveinfo += buff;
		Format(buff, L"<priority>%d</priority>", (*list)[i]->recSetting.priority);
		reserveinfo += buff;
		Format(buff, L"<tuijyuuFlag>%d</tuijyuuFlag>", (*list)[i]->recSetting.tuijyuuFlag);
		reserveinfo += buff;
		Format(buff, L"<serviceMode>%d</serviceMode>", (*list)[i]->recSetting.serviceMode);
		reserveinfo += buff;
		Format(buff, L"<pittariFlag>%d</pittariFlag>", (*list)[i]->recSetting.pittariFlag);
		reserveinfo += buff;
		Format(buff, L"<batFilePath>%s</batFilePath>", (*list)[i]->recSetting.batFilePath.c_str());
		reserveinfo += buff;
		reserveinfo += L"<recFolderList>";
		for( size_t j=0; j<(*list)[i]->recSetting.recFolderList.size(); j++ ){
			reserveinfo += L"<recFolderInfo>";
			Format(buff, L"<recFolder>%s</recFolder>", (*list)[i]->recSetting.recFolderList[j].recFolder.c_str());
			reserveinfo += buff;
			Format(buff, L"<writePlugIn>%s</writePlugIn>", (*list)[i]->recSetting.recFolderList[j].writePlugIn.c_str());
			reserveinfo += buff;
			Format(buff, L"<recNamePlugIn>%s</recNamePlugIn>", (*list)[i]->recSetting.recFolderList[j].recNamePlugIn.c_str());
			reserveinfo += buff;
			reserveinfo += L"</recFolderInfo>";
		}
		reserveinfo += L"</recFolderList>";
		Format(buff, L"<suspendMode>%d</suspendMode>", (*list)[i]->recSetting.suspendMode);
		reserveinfo += buff;
		Format(buff, L"<rebootFlag>%d</rebootFlag>", (*list)[i]->recSetting.rebootFlag);
		reserveinfo += buff;
		Format(buff, L"<useMargineFlag>%d</useMargineFlag>", (*list)[i]->recSetting.useMargineFlag);
		reserveinfo += buff;
		Format(buff, L"<startMargine>%d</startMargine>", (*list)[i]->recSetting.startMargine);
		reserveinfo += buff;
		Format(buff, L"<endMargine>%d</endMargine>", (*list)[i]->recSetting.endMargine);
		reserveinfo += buff;
		Format(buff, L"<continueRecFlag>%d</continueRecFlag>", (*list)[i]->recSetting.continueRecFlag);
		reserveinfo += buff;
		Format(buff, L"<partialRecFlag>%d</partialRecFlag>", (*list)[i]->recSetting.partialRecFlag);
		reserveinfo += buff;
		Format(buff, L"<tunerID>%d</tunerID>", (*list)[i]->recSetting.tunerID);
		reserveinfo += buff;
		reserveinfo += L"<partialRecFolder>";
		for( size_t j=0; j<(*list)[i]->recSetting.partialRecFolder.size(); j++ ){
			reserveinfo += L"<recFolderInfo>";
			Format(buff, L"<recFolder>%s</recFolder>", (*list)[i]->recSetting.partialRecFolder[j].recFolder.c_str());
			reserveinfo += buff;
			Format(buff, L"<writePlugIn>%s</writePlugIn>", (*list)[i]->recSetting.partialRecFolder[j].writePlugIn.c_str());
			reserveinfo += buff;
			Format(buff, L"<recNamePlugIn>%s</recNamePlugIn>", (*list)[i]->recSetting.partialRecFolder[j].recNamePlugIn.c_str());
			reserveinfo += buff;
			reserveinfo += L"</recFolderInfo>";
		}
		reserveinfo += L"</partialRecFolder>";
		reserveinfo += L"</recsetting>";

		reserveinfo += L"<recFileNameList>";
		for( size_t j=0; j<(*list)[i]->recFileNameList.size(); j++ ){
			Format(buff, L"<name>%s</name>", (*list)[i]->recFileNameList[j].c_str());
			reserveinfo += buff;
		}
		reserveinfo += L"</recFileNameList>";

		reserveinfo += L"</reserveinfo>";
	}
	xml += reserveinfo;
	xml += L"</items>";
	xml += L"</entry>";

	WtoUTF8(xml, utf8);

	sendParam->dataSize = (DWORD)utf8.size();
	sendParam->data = new BYTE[sendParam->dataSize];
	memcpy(sendParam->data, utf8.c_str(), sendParam->dataSize);
	if( sendParam->dataSize > 0 ){
		Format(sendParam->httpHeader, "HTTP/1.0 200 OK\r\nContent-Type: text/xml\r\nContent-Length: %d\r\nConnection: close\r\n\r\n", sendParam->dataSize);
	}else{
		sendParam->httpHeader = "HTTP/1.0 400 Bad Request\r\nConnection: close\r\n\r\n";
	}

	return ret;
}
Example #8
0
DWORD CRestApiManager::GetEnumEventInfo(string param, HTTP_STREAM* sendParam, CEpgDBManager* epgDB)
{
	DWORD ret = NO_ERR;

	map<string,string> paramMap;
	while(param.size()>0){
		string buff;
		Separate(param, "&", buff, param);
		if(buff.size()>0){
			string key;
			string val;
			Separate(buff, "=", key, val);
			paramMap.insert(pair<string,string>(key, val));
		}
	}

	map<string,string>::iterator itr;
	WORD ONID = 0xFFFF;
	itr = paramMap.find("ONID");
	if( itr != paramMap.end() ){
		ONID = (WORD)atoi(itr->second.c_str());
	}
	WORD TSID = 0xFFFF;
	itr = paramMap.find("TSID");
	if( itr != paramMap.end() ){
		TSID = (WORD)atoi(itr->second.c_str());
	}
	WORD SID = 0xFFFF;
	itr = paramMap.find("SID");
	if( itr != paramMap.end() ){
		SID = (WORD)atoi(itr->second.c_str());
	}
	WORD basicOnly = 1;
	itr = paramMap.find("basic");
	if( itr != paramMap.end() ){
		basicOnly = (WORD)atoi(itr->second.c_str());
	}
	DWORD index = 0;
	itr = paramMap.find("index");
	if( itr != paramMap.end() ){
		index = (DWORD)atoi(itr->second.c_str());
	}
	DWORD count = 200;
	itr = paramMap.find("count");
	if( itr != paramMap.end() ){
		count = (DWORD)atoi(itr->second.c_str());
	}

	vector<EPGDB_SERVICE_EVENT_INFO*> list;
	wstring xml = L"";
	string utf8 = "";
	if( epgDB->EnumEventAll(&list) == TRUE ){
		wstring buff = L"";
		DWORD total = 0;
		DWORD findCount = 0;

		xml += L"<?xml version=\"1.0\" encoding=\"UTF-8\" ?><entry>";

		wstring serviceinfo = L"";
		serviceinfo += L"<items>";
		for( size_t i=0; i<list.size(); i++ ){
			for( size_t j=0; j<list[i]->eventList.size(); j++){
				EPGDB_EVENT_INFO* eventInfo = list[i]->eventList[j];
				if( eventInfo->original_network_id != ONID && ONID != 0xFFFF ){
					continue;
				}
				if( eventInfo->transport_stream_id != TSID && TSID != 0xFFFF ){
					continue;
				}
				if( eventInfo->service_id != SID && SID != 0xFFFF ){
					continue;
				}
				if( total < index ){
					total++;
					continue;
				}
				if( index + count <= total ){
					total++;
					continue;
				}
				total++;
				findCount++;

				serviceinfo += L"<eventinfo>";
				Format(buff, L"<ONID>%d</ONID>", eventInfo->original_network_id);
				serviceinfo += buff;
				Format(buff, L"<TSID>%d</TSID>", eventInfo->transport_stream_id);
				serviceinfo += buff;
				Format(buff, L"<SID>%d</SID>", eventInfo->service_id);
				serviceinfo += buff;
				Format(buff, L"<eventID>%d</eventID>", eventInfo->event_id);
				serviceinfo += buff;
				if( eventInfo->StartTimeFlag == 1 ){
					Format(buff, L"<startDate>%d/%d/%d</startDate>", eventInfo->start_time.wYear, eventInfo->start_time.wMonth, eventInfo->start_time.wDay);
					serviceinfo += buff;
					Format(buff, L"<startTime>%d:%d:%d</startTime>", eventInfo->start_time.wHour, eventInfo->start_time.wMinute, eventInfo->start_time.wSecond);
					serviceinfo += buff;
					Format(buff, L"<startDayOfWeek>%d</startDayOfWeek>", eventInfo->start_time.wDayOfWeek);
					serviceinfo += buff;
				}
				if( eventInfo->DurationFlag == 1 ){
					Format(buff, L"<duration>%d</duration>", eventInfo->durationSec);
					serviceinfo += buff;
				}
				if( eventInfo->shortInfo != NULL ){
					wstring chk = eventInfo->shortInfo->event_name;
					CheckXMLChar(chk);
					Format(buff, L"<event_name>%s</event_name>", chk.c_str());
					serviceinfo += buff;

					chk = eventInfo->shortInfo->text_char;
					CheckXMLChar(chk);
					Format(buff, L"<event_text>%s</event_text>", chk.c_str());
					serviceinfo += buff;
				}
				if( eventInfo->contentInfo != NULL ){
					serviceinfo += L"";
					for( size_t k=0; k<eventInfo->contentInfo->nibbleList.size(); k++){
						wstring nibble = L"";
						Format(nibble,L"<contentInfo><nibble1>%d</nibble1><nibble2>%d</nibble2></contentInfo>", 
							eventInfo->contentInfo->nibbleList[k].content_nibble_level_1,
							eventInfo->contentInfo->nibbleList[k].content_nibble_level_2);
						serviceinfo += nibble;
					}
				}
				if( eventInfo->eventGroupInfo != NULL ){
					for( size_t k=0; k<eventInfo->eventGroupInfo->eventDataList.size(); k++){
						wstring group = L"";
						Format(group,L"<groupInfo><ONID>%d</ONID><TSID>%d</TSID><SID>%d</SID><eventID>%d</eventID></groupInfo>", 
							eventInfo->eventGroupInfo->eventDataList[k].original_network_id,
							eventInfo->eventGroupInfo->eventDataList[k].transport_stream_id,
							eventInfo->eventGroupInfo->eventDataList[k].service_id,
							eventInfo->eventGroupInfo->eventDataList[k].event_id
							);
						serviceinfo += group;
					}
				}

				Format(buff, L"<freeCAFlag>%d</freeCAFlag>", eventInfo->freeCAFlag);
				serviceinfo += buff;

				if( basicOnly == 0 ){
					if( eventInfo->extInfo != NULL ){
						wstring chk = eventInfo->extInfo->text_char;
						CheckXMLChar(chk);
						Format(buff, L"<event_ext_text>%s</event_ext_text>", chk.c_str());
						serviceinfo += buff;
					}
					if( eventInfo->componentInfo != NULL ){
						Format(buff, L"<videoInfo><stream_content>%d</stream_content><component_type>%d</component_type><component_tag>%d</component_tag><text>%s</text></videoInfo>", 
							eventInfo->componentInfo->stream_content,
							eventInfo->componentInfo->component_type,
							eventInfo->componentInfo->component_tag,
							eventInfo->componentInfo->text_char.c_str()
							);
						serviceinfo += buff;
					}
					if( eventInfo->audioInfo != NULL ){
						for( size_t k=0; k<eventInfo->audioInfo->componentList.size(); k++ ){
							Format(buff, L"<audioInfo><stream_content>%d</stream_content><component_type>%d</component_type><component_tag>%d</component_tag><stream_type>%d</stream_type><simulcast_group_tag>%d</simulcast_group_tag><ES_multi_lingual_flag>%d</ES_multi_lingual_flag><main_component_flag>%d</main_component_flag><quality_indicator>%d</quality_indicator><sampling_rate>%d</sampling_rate><text>%s</text></audioInfo>", 
								eventInfo->audioInfo->componentList[k].stream_content,
								eventInfo->audioInfo->componentList[k].component_type,
								eventInfo->audioInfo->componentList[k].component_tag,
								eventInfo->audioInfo->componentList[k].stream_type,
								eventInfo->audioInfo->componentList[k].simulcast_group_tag,
								eventInfo->audioInfo->componentList[k].ES_multi_lingual_flag,
								eventInfo->audioInfo->componentList[k].main_component_flag,
								eventInfo->audioInfo->componentList[k].quality_indicator,
								eventInfo->audioInfo->componentList[k].sampling_rate,
								eventInfo->audioInfo->componentList[k].text_char.c_str()
								);
							serviceinfo += buff;
						}
					}
					if( eventInfo->eventRelayInfo != NULL ){
						for( size_t k=0; k<eventInfo->eventRelayInfo->eventDataList.size(); k++){
							wstring group = L"";
							Format(group,L"<relayInfo><ONID>%d</ONID><TSID>%d</TSID><SID>%d</SID><eventID>%d</eventID></relayInfo>", 
								eventInfo->eventRelayInfo->eventDataList[k].original_network_id,
								eventInfo->eventRelayInfo->eventDataList[k].transport_stream_id,
								eventInfo->eventRelayInfo->eventDataList[k].service_id,
								eventInfo->eventRelayInfo->eventDataList[k].event_id
								);
							serviceinfo += group;
						}
					}
				}
				serviceinfo += L"</eventinfo>";

			}
			list[i]->eventList.clear();
			SAFE_DELETE(list[i]);
		}
		serviceinfo += L"</items>";

		Format(buff, L"<total>%d</total><index>%d</index><count>%d</count>", total, index, findCount);
		xml += buff;
		xml += serviceinfo;
		xml += L"</entry>";
	}else{
		xml += L"<?xml version=\"1.0\" encoding=\"UTF-8\" ?><entry>";
		xml += L"<err>EPGデータを読み込み中、または存在しません</err>";
		xml += L"</entry>";
	}

	WtoUTF8(xml, utf8);

	sendParam->dataSize = (DWORD)utf8.size();
	sendParam->data = new BYTE[sendParam->dataSize];
	memcpy(sendParam->data, utf8.c_str(), sendParam->dataSize);
	if( sendParam->dataSize > 0 ){
		Format(sendParam->httpHeader, "HTTP/1.0 200 OK\r\nContent-Type: text/xml\r\nContent-Length: %d\r\nConnection: close\r\n\r\n", sendParam->dataSize);
	}else{
		sendParam->httpHeader = "HTTP/1.0 400 Bad Request\r\nConnection: close\r\n\r\n";
	}

	return ret;
}
Example #9
0
BOOL CreateSignatureHMACSHA1(wstring src, wstring secretKey, wstring& signature)
{
	signature = L"";

	string hashSrc = "";
	string hashKey = "";
	WtoUTF8(src, hashSrc);
	WtoUTF8(secretKey, hashKey);

	HCRYPTPROV cryptProv = NULL;
	HCRYPTHASH cryptHash = NULL;
	BYTE key[65];
	DWORD keySize = 0;
	BYTE ipad[65];
	BYTE opad[65];
	ZeroMemory(key, 65);
	ZeroMemory(ipad, 65);
	ZeroMemory(opad, 65);

	BYTE* firstHash = NULL;
	DWORD firstHashSize = 0;
	BYTE* secondHash = NULL;
	DWORD secondHashSize = 0;

	WCHAR* base64 = NULL;
	DWORD base64Size = 0;

	if ( CryptAcquireContext(&cryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT) == FALSE ){
		goto Err_End;
	}

	if( hashKey.size() > 64 ){
		if ( CryptCreateHash(cryptProv, CALG_SHA1, 0, 0, &cryptHash) == FALSE ){
			goto Err_End;
		}
		if( CryptHashData(cryptHash, (BYTE*)hashKey.c_str(), (DWORD)hashKey.length(), 0) == FALSE ){
			goto Err_End;
		}
		if( CryptGetHashParam(cryptHash, HP_HASHVAL, NULL, &keySize, 0 ) == FALSE ){
			goto Err_End;
		}
		if( CryptGetHashParam(cryptHash, HP_HASHVAL, key, &keySize, 0 ) == FALSE ){
			goto Err_End;
		}
		CryptDestroyHash(cryptHash);
		cryptHash = NULL;
	}else{
		keySize = (DWORD)hashKey.size();
		memcpy(key, hashKey.c_str(), keySize);
	}
	memcpy(ipad, key, keySize);
	memcpy(opad, key, keySize);
	for( int i=0; i<64; i++ ){
		ipad[i] ^= 0x36;
		opad[i] ^= 0x5c;
	}

	if ( CryptCreateHash(cryptProv, CALG_SHA1, 0, 0, &cryptHash) == FALSE ){
		goto Err_End;
	}
	if( CryptHashData(cryptHash, ipad, 64, 0) == FALSE ){
		goto Err_End;
	}
	if( CryptHashData(cryptHash, (BYTE*)hashSrc.c_str(), (DWORD)hashSrc.size(), 0) == FALSE ){
		goto Err_End;
	}
	if( CryptGetHashParam(cryptHash, HP_HASHVAL, NULL, &firstHashSize, 0 ) == FALSE ){
		goto Err_End;
	}
	firstHash = new BYTE[firstHashSize];
	if( CryptGetHashParam(cryptHash, HP_HASHVAL, firstHash, &firstHashSize, 0 ) == FALSE ){
		goto Err_End;
	}
	CryptDestroyHash(cryptHash);
	cryptHash = NULL;

	if ( CryptCreateHash(cryptProv, CALG_SHA1, 0, 0, &cryptHash) == FALSE ){
		goto Err_End;
	}
	if( CryptHashData(cryptHash, opad, 64, 0) == FALSE ){
		goto Err_End;
	}
	if( CryptHashData(cryptHash, firstHash, firstHashSize, 0) == FALSE ){
		goto Err_End;
	}
	if( CryptGetHashParam(cryptHash, HP_HASHVAL, NULL, &secondHashSize, 0 ) == FALSE ){
		goto Err_End;
	}
	secondHash = new BYTE[secondHashSize];
	if( CryptGetHashParam(cryptHash, HP_HASHVAL, secondHash, &secondHashSize, 0 ) == FALSE ){
		goto Err_End;
	}
	CryptDestroyHash(cryptHash);
	cryptHash = NULL;

	//Base64
	if( CryptBinaryToString( secondHash, secondHashSize, CRYPT_STRING_BASE64, NULL, &base64Size ) == FALSE){
		goto Err_End;
	}
   base64 = new WCHAR[ base64Size + 1 ];
   if( CryptBinaryToString( secondHash, secondHashSize, CRYPT_STRING_BASE64, base64, &base64Size ) == FALSE ){
		goto Err_End;
   }
   signature = base64;
   //最後に\r\n入ってしまうみたいなので除去
   Replace(signature, L"\r\n", L"");

Err_End:
	SAFE_DELETE_ARRAY(base64);
	SAFE_DELETE_ARRAY(secondHash);
	SAFE_DELETE_ARRAY(firstHash);

	if( cryptHash !=NULL ){
		CryptDestroyHash(cryptHash);
	}
	if( cryptProv != NULL ){
		CryptReleaseContext(cryptProv, 0);
	}

	if( signature.size() > 0 ){
		return TRUE;
	}else{
		return FALSE;
	}
}