示例#1
0
void CFileMgrDB::UpdateFiles(CRBMap<FILEKEY,CFileTaskItem*> & FileList)
{
	CStringA strCmd, strCmd2;
	CHAR strHash[33];

	m_db->Exec("begin transaction");
	POSITION pos = FileList.GetHeadPosition();
	while (pos)
	{		
		FILEKEY fk = FileList.GetKeyAt(pos);
		CFileTaskItem *item = FileList.GetNextValue(pos);
		md4strA(fk.key, strHash);

		CStringA strPath = StrToUtf8(item->m_strFilePath), strUrl = StrToUtf8(item->m_strUrl), strName = StrToUtf8(item->m_FileName), strLink = StrToUtf8(item->m_strEd2kLink);
		strPath.Replace("'", "''");
		strUrl.Replace("'", "''");
		strName.Replace("'", "''");
		strLink.Replace("'", "''");
	
		strCmd2.Format("INSERT INTO files (hash, state, path, url, size, name, ed2klink, filetime, metbakid) "
			"VALUES ('%s',%u,'%s','%s',%I64u,'%s','%s',%I64u,%u)", strHash, item->m_nFileState, strPath, strUrl, item->m_FileSize, strName,
			strLink, item->m_tFiletime.GetTime(), item->m_metBakId);
		SQL_EXEC(strCmd2);
	}   
	m_db->Exec("end transaction");	
}
示例#2
0
STDMETHODIMP CBHttpRequest::Abort(void)
{
    s_cs.Enter();
    s_mapReq.RemoveKey(m_dwReqID);
    s_cs.Leave();

    if(m_hFile)
    {
        InternetCloseHandle(m_hFile);
        m_hFile = NULL;
    }

    if(m_hConnection)
    {
        InternetCloseHandle(m_hConnection);
        m_hConnection = NULL;
    }

    m_mStream.Clear();
    m_uulTotalBytes = 0;
    m_dwStatus = 0;
    m_nReadyState = 0;
    m_dwReadPos = 0;
    m_dwDataAvailable = 0;
    m_eventComplete.Reset();

    return S_OK;
}
示例#3
0
void CALLBACK CBHttpRequest::staticStatusCallback(HINTERNET hInternet, DWORD ReqID, DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength)
{
    CBHttpRequest* pHttp = NULL;

    s_cs.Enter();
    s_mapReq.Lookup(ReqID, pHttp);
    s_cs.Leave();

    if(pHttp)pHttp->StatusCallback(dwInternetStatus);
}
示例#4
0
//MOPRH START - Added by SiRoB, Slugfiller: modid
void CClientList::GetModStatistics(CRBMap<uint32, CRBMap<CString, uint32>* > *clientMods){
	if (!clientMods)
		return;
	clientMods->RemoveAll();
	
	// [TPT] Code improvement
	for (POSITION pos = list.GetHeadPosition(); pos != NULL;) {		
		CUpDownClient* cur_client =	list.GetNext(pos);

		switch (cur_client->GetClientSoft()) {
		case SO_EMULE   :
		case SO_OLDEMULE:
			break;
		default:
			continue;
		}

		CRBMap<CString, uint32> *versionMods;

		if (!clientMods->Lookup(cur_client->GetVersion(), versionMods)){
			versionMods = new CRBMap<CString, uint32>;
			versionMods->RemoveAll();
			clientMods->SetAt(cur_client->GetVersion(), versionMods);
		}

		uint32 count;

		if (!versionMods->Lookup(cur_client->GetClientModVer(), count))
			count = 1;
		else
			count++;

		versionMods->SetAt(cur_client->GetClientModVer(), count);
	}
	// [TPT] end
}
示例#5
0
CBBrowserCaps::CBBrowserCaps(LPCSTR pstrUserAgent) : m_strUserAgent(pstrUserAgent)
{
	Init();

	if(s_bcDatas.Lookup(m_strUserAgent, m_pData))
		return;

	size_t i;

	for(i = 0; i < s_bcDatasExt.GetCount(); i ++)
		if (MatchString((LPCSTR)s_bcDatasExt[i]->UserAgent, pstrUserAgent))
		{
			m_pData = s_bcDatasExt[i];
			break;
		}
}
示例#6
0
STDMETHODIMP CBHttpRequest::Open(BSTR strMethod, BSTR strUrl, VARIANT_BOOL bAsync, VARIANT varUser, VARIANT varPassword)
{
    CUrl url;
    CStringA strObject;
    CStringA strUser;
    CStringA strPassword;

    Abort();

    s_cs.Enter();
    s_dwReqID ++;
    m_dwReqID = s_dwReqID;
    s_mapReq.SetAt(m_dwReqID, this);
    s_cs.Leave();

    url.CrackUrl(CBStringA(strUrl));
    m_bAsync = (bAsync != VARIANT_FALSE);

    strObject = url.GetUrlPath();
    strObject.Append(url.GetExtraInfo());

    if(varUser.vt != VT_ERROR)
    {
        HRESULT hr = varGetString(varUser, strUser);
        if(FAILED(hr))return hr;
    }

    if(varPassword.vt != VT_ERROR)
    {
        HRESULT hr = varGetString(varPassword, strPassword);
        if(FAILED(hr))return hr;
    }

    m_hConnection = InternetConnect(m_hSession, url.GetHostName(), url.GetPortNumber(),
                                    strUser.IsEmpty() ? NULL : (LPCSTR)strUser, strPassword.IsEmpty() ? NULL : (LPCSTR)strPassword,
                                    INTERNET_SERVICE_HTTP, 0, m_dwReqID);
    if(m_hConnection == NULL)
        return GetErrorResult();

    m_hFile = HttpOpenRequest(m_hConnection, CBStringA(strMethod), strObject, NULL, NULL, NULL, m_dwFlags, m_dwReqID);
    if(m_hFile == NULL)
        return GetErrorResult();

    m_eventComplete.Set();

    return S_OK;
}
示例#7
0
void CBBrowserCaps::Init(void)
{
	if(s_bInited)return;

	s_csBrowserCaps.Enter();
	if(s_bInited)
	{
		s_csBrowserCaps.Leave();
		return;
	}

	CBComPtr<_Data> pData;
	int n;
	BOOL bFind = FALSE;

	pData.CreateInstance();

	CBComPtr<CBFile> pFile;
	CBStringA strLine;

	pFile.CreateInstance();
	if(SUCCEEDED(pFile->Open(L"\\browscap.ini")))
	{
		while(SUCCEEDED(pFile->ReadLine(strLine)))
		{
			strLine.Trim();
			if(!strLine.IsEmpty())
				if(strLine[0] == '[' && strLine[strLine.GetLength() - 1] == ']')
				{
					pData.CreateInstance();
					pData->UserAgent = strLine.Mid(1, strLine.GetLength() - 2);

					if(pData->UserAgent.Find('*') == -1 && pData->UserAgent.Find('?') == -1)
						s_bcDatas.SetAt(pData->UserAgent, pData);
					else s_bcDatasExt.Add(pData);

					if(!pData->UserAgent.Compare("*"))
						bFind = TRUE;
				}else if(strLine[0] != ';')
				{
					n = strLine.Find('=');
					if(n != -1)
					{
						CBStringA strName, strValue;

						strName = strLine.Left(n).Trim();
						if(!strName.IsEmpty())
						{
							strValue = strLine.Mid(n + 1).Trim();
							if(!strName.CompareNoCase("parent"))
							{
								CBComPtr<_Data> pParentData;
								
								if(s_bcDatas.Lookup(strValue, pParentData))
								{
									pData->Name = pParentData->Name;
									pData->Type = pParentData->Type;
									pData->Version = pParentData->Version;
									pData->MajorVersion = pParentData->MajorVersion;
									pData->MinorVersion = pParentData->MinorVersion;
									pData->Platform = pParentData->Platform;
									pData->CSSVersion = pParentData->CSSVersion;
									pData->Frames = pParentData->Frames;
									pData->IFrames = pParentData->IFrames;
									pData->Tables = pParentData->Tables;
									pData->Cookies = pParentData->Cookies;
									pData->BackgroundSounds = pParentData->BackgroundSounds;
									pData->VBScript = pParentData->VBScript;
									pData->JavaScript = pParentData->JavaScript;
									pData->JavaApplets = pParentData->JavaApplets;
									pData->ActiveXControls = pParentData->ActiveXControls;
									pData->CDF = pParentData->CDF;
									pData->AOL = pParentData->AOL;
									pData->Beta = pParentData->Beta;
									pData->Win16 = pParentData->Win16;
									pData->Crawler = pParentData->Crawler;
									pData->WAP = pParentData->WAP;
									pData->NetCLR = pParentData->NetCLR;
								}
							}
							else if(!strName.CompareNoCase("browser"))
							{
								pData->Name = strValue;

								pData->Type = pData->Name;
								if(!pData->MajorVersion.IsEmpty() && pData->MajorVersion.Compare(L"0"))
								{
									pData->Type += ' ';
									pData->Type += pData->MajorVersion;
								}
							}
							else if(!strName.CompareNoCase("Version"))
								pData->Version = strValue;
							else if(!strName.CompareNoCase("MajorVer"))
							{
								pData->MajorVersion = strValue;

								pData->Type = pData->Name;
								if(!pData->MajorVersion.IsEmpty() && pData->MajorVersion.Compare(L"0"))
								{
									pData->Type += ' ';
									pData->Type += pData->MajorVersion;
								}
							}
							else if(!strName.CompareNoCase("MinorVer"))
								pData->MinorVersion = strValue;
							else if(!strName.CompareNoCase("Platform"))
								pData->Platform = strValue;
							else if(!strName.CompareNoCase("CSS"))
								pData->CSSVersion = atoi(strValue);
							else if(!strName.CompareNoCase("Frames"))
								pData->Frames = !strValue.CompareNoCase("true");
							else if(!strName.CompareNoCase("IFrames"))
								pData->IFrames = !strValue.CompareNoCase("true");
							else if(!strName.CompareNoCase("Tables"))
								pData->Tables = !strValue.CompareNoCase("true");
							else if(!strName.CompareNoCase("Cookies"))
								pData->Cookies = !strValue.CompareNoCase("true");
							else if(!strName.CompareNoCase("BackgroundSounds"))
								pData->BackgroundSounds = !strValue.CompareNoCase("true");
							else if(!strName.CompareNoCase("VBScript"))
								pData->VBScript = !strValue.CompareNoCase("true");
							else if(!strName.CompareNoCase("JavaScript"))
								pData->JavaScript = !strValue.CompareNoCase("true");
							else if(!strName.CompareNoCase("JavaApplets"))
								pData->JavaApplets = !strValue.CompareNoCase("true");
							else if(!strName.CompareNoCase("ActiveXControls"))
								pData->ActiveXControls = !strValue.CompareNoCase("true");
							else if(!strName.CompareNoCase("CDF"))
								pData->CDF = !strValue.CompareNoCase("true");
							else if(!strName.CompareNoCase("AOL"))
								pData->AOL = !strValue.CompareNoCase("true");
							else if(!strName.CompareNoCase("Beta"))
								pData->Beta = !strValue.CompareNoCase("true");
							else if(!strName.CompareNoCase("Win16"))
								pData->Win16 = !strValue.CompareNoCase("true");
							else if(!strName.CompareNoCase("Crawler"))
								pData->Crawler = !strValue.CompareNoCase("true");
							else if(!strName.CompareNoCase("WAP"))
								pData->WAP = !strValue.CompareNoCase("true");
							else if(!strName.CompareNoCase("NetCLR"))
								pData->NetCLR = !strValue.CompareNoCase("true");
						}
					}
				}
		}
	}

	if(!bFind)
	{
		pData.CreateInstance();
		pData->UserAgent = "*";
		s_bcDatasExt.Add(pData);
	}

	qsort(s_bcDatasExt.GetData(), s_bcDatasExt.GetCount(), sizeof(CBComPtr<_Data>),
		(int (__cdecl *)(const void *,const void *))staticCompare);

	s_bInited = TRUE;
	s_csBrowserCaps.Leave();
}
示例#8
0
void CBBrowserCaps::Clear(void)
{
	s_bcDatas.RemoveAll();
	s_bcDatasExt.RemoveAll();
}