Exemplo n.º 1
0
void CGenethonDoc::writeToReport(CString& output) {
    if (m_pTextView == NULL) {

        ((CMainFrame *)(AfxGetApp()->m_pMainWnd))->OpenTextView();
    }
    else {

        m_pTextView->GetParentFrame()->ActivateFrame();
        m_pTextView->Invalidate();
    }

    CMemFile* memFile = new CMemFile();
    //serialize object into the pData
    //	char* cBuff = new char[128];
    //	sprintf_s(cBuff, 128, "%s", "Test test test test test test\n");

    memFile->Write(output, output.GetLength());
    memFile->SeekToBegin();

    //	txtFile->Open(PathName, CFile::modeRead);
    //	CArchive archive(&txtFile, CArchive::load);

    //	SerializeRaw( archive );
    m_pTextView->LoadMemfile(memFile);

    memFile->Close();
    delete memFile;
}
Exemplo n.º 2
0
void CUpdateServersDlg::OnTimer(UINT_PTR nIDEvent)
{
	CSkinDialog::OnTimer( nIDEvent );

	if ( m_pRequest.IsPending() )
	{
		int n = m_wndProgress.GetPos();
		if ( n < 5 )
			n = 5;
		else if ( n < 100 )
			n++;
		m_wndProgress.SetPos( n );
	}
	else
	{
		KillTimer( 1 );

		if ( m_pRequest.GetStatusSuccess() )
		{
			const CString strExt = CString( PathFindExtension( m_sURL ) ).MakeLower();
			if ( strExt == L".met" || m_sURL.Find( _T("//server"), 8 ) > 8 )		// || strExt == L".php"
				Settings.eDonkey.ServerListURL = m_sURL;
			else if ( strExt == L".bz2" || m_sURL.Find( _T("hublist"), 8 ) > 8 )
				Settings.DC.HubListURL = m_sURL;
		//	else if ( strExt == L".xml" )
		//		Settings.Gnutella.CacheURL = m_sURL;
		//	else if ( strExt == L".dat" )
		//		Settings.KAD.NodesListURL = m_sURL;

			const CBuffer* pBuffer = m_pRequest.GetResponseBuffer();

			CMemFile pFile;
			pFile.Write( pBuffer->m_pBuffer, pBuffer->m_nLength );
			pFile.Seek( 0, CFile::begin );

			if ( ( strExt == L".bz2" && HostCache.ImportHubList( &pFile ) ) ||
				 HostCache.ImportMET( &pFile ) )
			//	 HostCache.ImportCache( &pFile ) || 	// ToDo: G2/Gnutella loading
			//	 HostCache.ImportNodes( &pFile ) )		// ToDo: KAD
			{
				HostCache.Save();

				m_sURL.Empty();
				EndDialog( IDOK );
				return;
			}
		}

		CString strError;
		strError.Format( LoadString( IDS_DOWNLOAD_DROPPED ), m_sURL );
		MsgBox( strError, MB_OK | MB_ICONEXCLAMATION );

		m_sURL.Empty();
		EndDialog( IDCANCEL );
	}

	UpdateWindow();
}
void CDonkeyServersDlg::OnRun()
{
	if ( m_hInternet == NULL ) return;

	HINTERNET hRequest = InternetOpenUrl( m_hInternet, m_sURL, NULL, 0,
		INTERNET_FLAG_RELOAD|INTERNET_FLAG_DONT_CACHE, 0 );

	if ( hRequest == NULL )
	{
		InternetCloseHandle( m_hInternet );
		m_hInternet = NULL;
		PostMessage( WM_TIMER, FALSE );
		return;
	}

	DWORD nLength, nlLength = 4;
	DWORD nRemaining = 0;
	BYTE pBuffer[1024];
	CMemFile pFile;

	if ( HttpQueryInfo( hRequest, HTTP_QUERY_CONTENT_LENGTH|HTTP_QUERY_FLAG_NUMBER,
		&nLength, &nlLength, NULL ) )
	{
		m_wndProgress.PostMessage( PBM_SETRANGE32, 0, nLength );
	}

	nLength = 0;

	while ( InternetQueryDataAvailable( hRequest, &nRemaining, 0, 0 ) && nRemaining > 0 )
	{
		nLength += nRemaining;
		m_wndProgress.PostMessage( PBM_SETPOS, nLength );

		while ( nRemaining > 0 )
		{
			DWORD nBuffer = min( nRemaining, DWORD(1024) );
			InternetReadFile( hRequest, pBuffer, nBuffer, &nBuffer );
			pFile.Write( pBuffer, nBuffer );
			nRemaining -= nBuffer;
		}
	}

	pFile.Seek( 0, CFile::begin );

	BOOL bSuccess = HostCache.eDonkey.ImportMET( &pFile );
	if ( bSuccess ) HostCache.Save();

	InternetCloseHandle( m_hInternet );
	m_hInternet = NULL;

	PostMessage( WM_TIMER, bSuccess ? 1 : 0 );
}
Exemplo n.º 4
0
CMapMgrDoc::CMapMgrDoc() {
	// TODO: add one-time construction code here
	HRSRC hRes = ::FindResource( AfxGetResourceHandle(), "HIST_UNCOMPR", "COLORPARAM" );
	if( NULL != hRes ) {
		HGLOBAL	hMem = ::LoadResource( AfxGetResourceHandle(), hRes );
		DWORD	dwSize = ::SizeofResource( AfxGetResourceHandle(), hRes );
		HPBYTE pData = (HPBYTE) ::LockResource( hMem );
		CMemFile memFile;
		memFile.Write( (LPVOID) pData, dwSize );
		memFile.SeekToBegin();

		CArchive	ar( &memFile, CArchive::load );
		WORD v;		// Version
		ar >> v;
		m_listOfFilters.Serialize( ar );

		UnlockResource( hMem );
		FreeResource( hMem );
	}
DWORD SupFileSubtitleProvider::ThreadProc()
{
    CFile f;
    if (!f.Open(m_fname, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
        return 1;
    }

    f.SeekToBegin();

    CMemFile sub;
    sub.SetLength(f.GetLength());
    sub.SeekToBegin();

    int len;
    BYTE buff[65536];
    while ((len = f.Read(buff, sizeof(buff))) > 0) {
        sub.Write(buff, len);
    }
    sub.SeekToBegin();

    WORD sync              = 0;
    USHORT size            = 0;
    REFERENCE_TIME rtStart = 0;

    CAutoLock cAutoLock(&m_csCritSec);
    while (sub.GetPosition() < (sub.GetLength() - 10)) {
        sync = (WORD)ReadByte(&sub, 2);
        if (sync == 'PG') {
            rtStart = UINT64(ReadByte(&sub, 4) * (1000 / 9));
            sub.Seek(4 + 1, CFile::current); // rtStop + Segment type
            size = ReadByte(&sub, 2) + 3;    // Segment size
            sub.Seek(-3, CFile::current);
            sub.Read(buff, size);
            m_pSub->ParseSample(buff, size, rtStart, 0);
        } else {
            break;
        }
    }

    sub.Close();

    return 0;
}
Exemplo n.º 6
0
bool CPackets::WriteStripSnapshot(UINT JobID, UINT StripRows, CSnapshot& Snap)
{
	CMemFile	mf;
	FRAP_STRIP_SNAPSHOT_HDR	hdr;
	ZeroMemory(&hdr, sizeof(hdr));
	mf.Write(&hdr, sizeof(hdr));	// reserve space for header
	{
		CArchive	ar(&mf, CArchive::store);
		Snap.Serialize(ar);
	}
	DWORD	PktLen = static_cast<DWORD>(mf.GetLength());
	DWORD	SnapLen = PktLen - sizeof(FRAP_STRIP_SNAPSHOT_HDR);
	FRAP_STRIP_SNAPSHOT	*pp = (FRAP_STRIP_SNAPSHOT *)mf.Detach();
	InitHdr(*pp, PMID_STRIP_SNAPSHOT, PktLen);
	pp->JobID = JobID;
	pp->StripRows = StripRows;
	pp->SnapLen = SnapLen;
	bool	retc = Write(*pp, PktLen);
	delete pp;	// buffer detached from CMemFile
	return(retc);
}
Exemplo n.º 7
0
//*********************************************************************************
static void createSnapshotTestSectrion()
{
    CTBSection xCurrentUser;
    xCurrentUser.Open(&CTBSection::tbRootSection, "CurrentUser");

    CTBSection xSnapshotTest;
    xSnapshotTest.Create(&xCurrentUser, "SnapshotTest", 0);
    //--------------------------------------------------------------
    {
        CTBSection xSection1;
        xSection1.Create(&xSnapshotTest, "Section1", 0);
    }
    //--------------------------------------------------------------
    CMemFile memFile;

    for(int i = 0; i < 64; ++i)
    {
        BYTE buff[1024] = {0};
        memset(buff, i, sizeof(buff));
        memFile.Write(buff, sizeof(buff));
    }
    //--------------------------------------------------------------
    xSnapshotTest.SetLongBinary("Blob1", &memFile);

    for(int i = 0; i < 200; ++i)
    {
        CTBValue vName("Name");
        CTBValue vAge(i);
        
        CString name, age;
        name.Format("Name %d", i);
        age.Format("Age %d", i);

        xSnapshotTest.SetValue(name, &vName);
        xSnapshotTest.SetValue(age, &vAge);
    }
    //--------------------------------------------------------------
    xSnapshotTest.Update();
}
Exemplo n.º 8
0
void CDonkeyServersDlg::OnTimer(UINT_PTR nIDEvent)
{
	CSkinDialog::OnTimer( nIDEvent );

	if ( m_pRequest.IsPending() )
	{
		int n = m_wndProgress.GetPos();
		if ( ++n >= 100 )
			n = 0;
		m_wndProgress.SetPos( n );
	}
	else
	{
		KillTimer( 1 );

		if ( m_pRequest.GetStatusSuccess() )
		{
			const CBuffer* pBuffer = m_pRequest.GetResponseBuffer();

			CMemFile pFile;
			pFile.Write( pBuffer->m_pBuffer, pBuffer->m_nLength );
			pFile.Seek( 0, CFile::begin );

			if ( HostCache.ImportMET( &pFile ) )
				HostCache.Save();
		}
		else
		{
			CString strError;
			strError.Format( LoadString( IDS_DOWNLOAD_DROPPED ), m_sURL );
			AfxMessageBox( strError, MB_OK | MB_ICONEXCLAMATION );
		}

		EndDialog( IDOK );
	}

	UpdateWindow();
}
Exemplo n.º 9
0
void CFTPProtocolOutput::WriteLine(const CString& cszLine, COLORREF crText)
{
   if( m_hWnd )
   {
      CHARFORMAT cf;
      cf.dwMask    = CFM_BOLD|CFM_COLOR;
      cf.dwEffects = CFE_BOLD;
      cf.crTextColor = crText;

      CMemFile mf;
      mf.Write(nsHelper::CCnv::ConvertToString(tstring(cszLine)).c_str(), cszLine.GetLength());
      mf.SeekToBegin();
   
      SetSelectionCharFormat(cf);

      EDITSTREAM es;
      es.dwCookie = reinterpret_cast<DWORD_PTR>(&mf);
      es.pfnCallback = CFTPProtocolOutput::ProtocolStreamInCallback; 
      StreamIn(SF_TEXT|SFF_SELECTION, es);
      SetSel(-1, -1);
      LineScroll(1);
   }
}