Esempio n. 1
0
//添加槽
void HomePage::addSlot()
{
    //获取图片
/*
    QStringList Stringlist = QFileDialog::getOpenFileNames(this,"Open file",QDir::currentPath(),tr("(*.png)"));

    if (Stringlist.size() == 0)
    {
        return;
    }
*/



    //PItemData->BGKImage = Stringlist.at(i);

    PItemData->BGKImage = ":/image/2.png";
    PItemData->ID = 0;

    emit sendUrl(*PItemData);



    QStandardItem *Item = new QStandardItem;

    Item->setSizeHint(QSize(60,60));         //设置Item大小为了美观

    QVariant photoUrl(PItemData->BGKImage);

    Item->setData(photoUrl.toString(),Qt::UserRole);

    StandardItemModel->appendRow(Item);      //追加Item


}
Esempio n. 2
0
int CCrawl::POST_multipart_Html(const string &url, const map<string, string> &multipartdata)
{
	setRequestMode(POST_multipart);
	m_CRequestUrl.setCRequestUrl(url);
	try
	{
		sendUrl(m_httpRequest);
		sendMultipartHeaders(m_httpRequest, multipartdata);
		m_httpRequest->initCurlData();
		sendProxy(m_httpRequest);
		m_httpRequest->getHeaderData();
		m_httpRequest->getWritaData();
		m_httpRequest->perform();

	}catch(std::exception &e)
	{
		cout<<e.what()<<endl;
		return 0;
	}catch(...)
	{
		printf("error catch! \n");
		return 0;
	}
	return response_status_function();
}
Esempio n. 3
0
QUrl BounceProxyUrl::getDeleteChannelUrl(const QString& mcid) const {
    QUrl sendUrl(bounceProxyChannelsBaseUrl);
    QString path = sendUrl.path();
    path.append(mcid);
    path.append(URL_PATH_SEPARATOR());
    sendUrl.setPath(path);
    return sendUrl;
}
Esempio n. 4
0
QUrl BounceProxyUrl::getBounceProxyBaseUrl() const {
    QUrl sendUrl(bounceProxyChannelsBaseUrl);
    QString path = sendUrl.path();
    if(!path.endsWith(URL_PATH_SEPARATOR())) {
        path.append(URL_PATH_SEPARATOR());
    }
    sendUrl.setPath(path);
    return sendUrl;
}
Esempio n. 5
0
Url BounceProxyUrl::getSendUrl(const std::string& channelId) const
{
    Url sendUrl(bounceProxyChannelsBaseUrl);
    std::string path = sendUrl.getPath();
    path.append(channelId);
    path.append(URL_PATH_SEPARATOR());
    path.append(SEND_MESSAGE_PATH_APPENDIX());
    path.append(URL_PATH_SEPARATOR());
    sendUrl.setPath(path);
    return sendUrl;
}
Esempio n. 6
0
QString  ChannelUrlSelector::constructUrl(const QString& baseUrl){
    QUrl sendUrl(baseUrl);
    QString path = sendUrl.path();
    if(!path.endsWith("/")) {
        path.append("/");
    }
    path.append(BounceProxyUrl::SEND_MESSAGE_PATH_APPENDIX());
    path.append("/");
    sendUrl.setPath(path);
    return sendUrl.toString();
}
Esempio n. 7
0
QUrl BounceProxyUrl::getSendUrl(const QString& channelId) const {
    QUrl sendUrl(bounceProxyChannelsBaseUrl);
    QString path = sendUrl.path();
    if(!path.endsWith(URL_PATH_SEPARATOR())) {
        path.append(URL_PATH_SEPARATOR());
    }
    path.append(channelId);
    path.append(URL_PATH_SEPARATOR());
    path.append(SEND_MESSAGE_PATH_APPENDIX());
    path.append(URL_PATH_SEPARATOR());
    sendUrl.setPath(path);
    return sendUrl;
}
Esempio n. 8
0
int CCrawl::getResponseData()
{
	try
	{
	sendUrl(m_httpRequest);
	sendHeaders(m_httpRequest);
	m_httpRequest->initCurlData();
	sendProxy(m_httpRequest);
	m_httpRequest->getHeaderData();
	if(m_requestMode == GET)
	{
        LOG4CPLUS_DEBUG(ClogCPP::m_logger,"http request mode: GET");
		m_httpRequest->perform();
		m_httpRequest->getContentType();
	    if(m_httpRequest->m_contentType.find("text", 0) == 0)
	    {
			m_httpRequest->getWritaData();
			m_httpRequest->perform();
	    }
	    else if(m_httpRequest->m_contentType.find("image", 0) == 0) //app faild
	    {
			string cmd = string("wget -P ./ ")+m_CRequestUrl.getCRequestUrl();
			//cout<<cmd<<endl;
			system(cmd.c_str());
			//m_httpRequest->getWritaDataToFile(m_CRequestUrl.getFilename());
			//m_httpRequest->perform();
	    }
	}
	if(m_requestMode == POST)
	{
        LOG4CPLUS_DEBUG(ClogCPP::m_logger,"http request mode: POST");
		sendPostdata(m_httpRequest);
		m_httpRequest->getWritaData();
		m_httpRequest->perform();
	}
	}catch(std::exception &e)
	{
		cout<<e.what()<<endl;
		return 0;
	}catch(...)
	{
		printf("error catch! \n");
		return 0;
	}

}
Esempio n. 9
0
int CCrawl::GET_Html(const string &url, const string &imagefilename)
{
	setRequestMode(GET);
	m_CRequestUrl.setCRequestUrl(url);
	m_CRequestUrl.setFilename(imagefilename);

	try
	{
		sendUrl(m_httpRequest);
		sendHeaders(m_httpRequest);
		m_httpRequest->initCurlData();
		sendProxy(m_httpRequest);
		m_httpRequest->getHeaderData();
		m_httpRequest->perform();
		m_httpRequest->getContentType();
	    if(m_httpRequest->m_contentType.find("text", 0) == 0)
	    {
			m_httpRequest->getWritaData();
			m_httpRequest->perform();
	    }
	    else if(m_httpRequest->m_contentType.find("image", 0) == 0) //img
	    {
			string cmd = string("wget -P ./ ")+m_CRequestUrl.getCRequestUrl();
			//cout<<cmd<<endl;
			system(cmd.c_str());
			//m_httpRequest->getWritaDataToFile(m_CRequestUrl.getFilename());
			//m_httpRequest->perform();
	    }

	}catch(std::exception &e)
	{
		cout<<e.what()<<endl;
		return 0;
	}catch(...)
	{
		printf("error catch! \n");
		return 0;
	}
	return response_status_function();
}
Esempio n. 10
0
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;
}
Esempio n. 11
0
Url BounceProxyUrl::getBounceProxyChannelsBaseUrl() const
{
    Url sendUrl(bounceProxyChannelsBaseUrl);
    return sendUrl;
}