Exemple #1
0
void CXmlReader::GetNodeName(std_string &strName)
{
	strName.clear();
	if (m_pOpenElement)
	{
		const char* p = m_pOpenElement->Value();
		if (p != NULL)
		{
			strName = UTF8ToTChar(p);
		}
	}
}
Exemple #2
0
void CXmlReader::GetNodeContent(std_string &strText)
{
	strText.clear();
	if (m_pOpenElement)
	{
		const char* p = m_pOpenElement->GetText();
		if (p != NULL)
		{
			strText = UTF8ToTChar(p);
		}
	}
}
Exemple #3
0
void CXmlReader::GetNodeAttribute(LPCTSTR szKey, std_string &strValue)
{
	strValue.clear();

	if (m_pOpenElement) 
	{
		const char* p = m_pOpenElement->Attribute(TCharToUTF8(szKey));
		if (p != NULL)
		{
			strValue = UTF8ToTChar(p);
		}
	}
}
Exemple #4
0
HRESULT CUpdateCheckEx::DownloadInfoFile(BYTE** ppbData, std_string& strError)
{
	if(ppbData == NULL) { ASSERT(FALSE); return E_POINTER; }
	*ppbData = NULL;

	/* TCHAR tszFile[MAX_PATH + 34];
	ZeroMemory(tszFile, sizeof(TCHAR) * (MAX_PATH + 34));

	URLDownloadToCacheFile(NULL, PWM_URL_VERSION, tszFile, URLOSTRM_GETNEWESTVERSION,
		0, NULL);

	if(_tcslen(tszFile) != 0)
	{
		FILE* fp = NULL;
		_tfopen_s(&fp, tszFile, _T("rb"));

		if(fp != NULL)
		{
			fseek(fp, 0, SEEK_END);
			const DWORD uFileSize = static_cast<DWORD>(ftell(fp));
			fseek(fp, 0, SEEK_SET);

			if(uFileSize != 0)
			{
				BYTE* pDataBuf = new BYTE[uFileSize + 2];

				fread(pDataBuf, 1, uFileSize, fp);
				fclose(fp);

				pDataBuf[uFileSize] = 0;
				pDataBuf[uFileSize + 1] = 0;

				*ppbData = pDataBuf;
			}
			else
			{
				strError = TRL("Cache error (cannot open cached file).");
				return E_ACCESSDENIED;
			}
		}
		else
		{
			strError = TRL("Cache error (cannot open cached file).");
			return E_ACCESSDENIED;
		}
	}
	else
	{
		strError = TRL("Connect failed, cannot check for updates.");
		return E_ACCESSDENIED;
	} */

	CKpInternetStream s(PWM_URL_VERSION, false);
	s.SetConnectOptions(5000, 1);
	s.SetTransferOptions(5000);

	std::vector<BYTE> vData;
	HRESULT r = s.ReadToEnd(vData);
	s.Close();
	if(FAILED(r) || (vData.size() == 0))
	{
		strError = TRL("Connect failed, cannot check for updates.");
		return r;
	}

	*ppbData = new BYTE[vData.size() + 2];
	(*ppbData)[vData.size()] = 0;
	(*ppbData)[vData.size() + 1] = 0;
	memcpy(*ppbData, &vData[0], vData.size());

	strError.clear();
	return S_OK;
}