Esempio n. 1
0
LRESULT CWzFtpPg1::OnPageChange(WPARAM wParam, LPARAM lParam)
{
	if ( wParam != 1 ) return 0;

	UpdateData( TRUE );

	CRKey *pRk = (CRKey*)CWzFrame::GetData( GetSafeHwnd() );
	if ( pRk == NULL ) return 0;

	pRk->Set( "Address", m_sAddr );	
	pRk->Set( "HttpPath", m_sHttpPath );	
	pRk->Set( "ServerName", m_sName );	
	pRk->Set( "Folder", m_sFolder );	

	if ( m_sName.IsEmpty() )
	{	::MessageBox(	GetSafeHwnd(), "Server Name cannot be blank",
		"Blank Field", MB_OK | MB_ICONSTOP ); return 1; }

	if ( m_sAddr.IsEmpty() )
	{	::MessageBox(	GetSafeHwnd(), "Server Address cannot be blank",
		"Blank Field", MB_OK | MB_ICONSTOP ); return 1; }

	if ( m_sHttpPath.IsEmpty() )
	{	::MessageBox(	GetSafeHwnd(), "HTTP Path cannot be blank",
		"Blank Field", MB_OK | MB_ICONSTOP ); return 1; }

	return 0;
}
Esempio n. 2
0
BOOL CStackReport::CallStack(CReg *pReg, CStackTrace *pSt )
{_STT();
	CTlLocalLock ll( *pSt );
	if ( !ll.IsLocked() ) return FALSE;

	// Reset object
	pReg->Destroy();

	DWORD dwThreadId = GetCurrentThreadId();

	char szMsg[ 256 ] = "";
	CStackTrace::iterator it = NULL;
	CStackTrace::list *pList = pSt->GetList();
	while ( NULL != ( it = pList->next( it ) ) )
	{
		wsprintf( szMsg, "Thread %lu ( 0x%lx )", *it->key(), *it->key() );

		CRKey *pRk = pReg->GetKey( szMsg );
		if ( pRk )
		{
			// Flag if this is the current thread
			if ( dwThreadId == *it->key() ) pRk->Set( "current_thread", dwThreadId );
			
			// Save the thread id
			pRk->Set( "thread_id", (DWORD)*it->key() );

			// Get stack information
			UINT uStack = (*it)->GetStackPtr();
			LPCTSTR *pStack = (*it)->GetStack();

			// Save
			if ( uStack ) for ( UINT i = 0, p = uStack - 1; i < uStack; i++, p-- )
			{
				wsprintf( szMsg, "f_%lu", i );

				// If we have a valid string
				if ( pStack[ i ] ) pRk->Set( szMsg, pStack[ p ] );

			} // end for

		} // end if

	} // end while

	return TRUE;
}
Esempio n. 3
0
LRESULT CWzEmailPg2::OnPageClose(WPARAM wParam, LPARAM lParam)
{
	UpdateData( TRUE );

	CRKey *pRk = (CRKey*)CWzFrame::GetData( GetSafeHwnd() );
	if ( pRk == NULL ) return -1;

	int sel = m_comboAuthType.GetCurSel();
	if ( sel != CB_ERR ) m_dwAuthType = m_comboAuthType.GetItemData( sel );

	pRk->Set( "AuthDetect", (DWORD)m_bAuthDetect ? 1 : 0 );
	pRk->Set( "Login", (DWORD)m_bLogin ? 1 : 0 );
	pRk->Set( "AuthType", m_dwAuthType );
	pRk->Set( "Username", m_sUsername );
	pRk->Set( "Password", m_sPassword );

	return 0;
}
Esempio n. 4
0
void CPgPubExtra::OnSettings() 
{
	CReg *pReg = (CReg*)CDlgTabFrame::GetData( GetSafeHwnd() );
	if ( pReg == NULL ) return;
	CRKey *pRk = pReg->FindKey( "PUBINFO" );
	if ( pRk == NULL ) return;

	int sel = m_comboCodec.GetCurSel();
	if ( sel == CB_ERR ) return;

	// Get data pointer
	LPCODECINFO pci = (LPCODECINFO)m_comboCodec.GetItemData( sel );
	if ( pci == NULL || !m_codecs.VerifyPointer( pci ) ) return;

	// Attempt to open settings dialog
	HIC hIc = ICOpen( ICTYPE_VIDEO, pci->fourCC, ICMODE_QUERY );
	if ( hIc != NULL )
	{
		DWORD size = pRk->GetValueSize( "CodecData" );
		LPBYTE buf = (LPBYTE)pRk->GetValuePtr( "CodecData" );

		// Restore settings
		if ( size > 0 && buf != NULL )
			ICSetState( hIc, buf, size );

		// Configure the compressor
		if ( ICConfigure( hIc, GetSafeHwnd() ) != ICERR_OK )
			return;

		size = ICGetStateSize( hIc );
		if ( size > 0 )
		{
			TMem< BYTE > mem;
			if ( mem.allocate( size ) )
				if ( ICGetState( hIc, mem.ptr(), size ) == ICERR_OK )
					pRk->Set( "CodecData", mem.ptr(), size );

		} // end if

		ICClose( hIc ); 

	} // end if
	
}
Esempio n. 5
0
// wjr 11/10/06...
BOOL CStackReport::ErrorLog(CReg *pReg, CErrLog* pErrLog )
{_STT();
	if( !pReg || !pErrLog )
		return E_INVALIDARG;

	CTlLocalLock ll( *pErrLog );
	if ( !ll.IsLocked() ) return FALSE;

	// Reset object
	pReg->Destroy();

	int	iId = 1;
	char szMsg[ 256 ] = "";
	LPERRORITEMINFO pEii = NULL;
	while ( ( pEii = (LPERRORITEMINFO)pErrLog->GetNext( pEii ) ) != NULL )
	{
		wsprintf( szMsg, "Error %d", iId++ );

		CRKey *pRk = pReg->GetKey( szMsg );
		if ( pRk )
		{
			CWinTime wt;
			wt.SetUnixTime( pEii->dwTime );
			wt.GetString( szMsg, "%w %b %D %Y - %g:%m:%s" );

			// Save the time.
			pRk->Set( "time", szMsg );
			
			// Save function info if present.
			if( pEii->sFile && pEii->sFunction )
			{
				if( pEii->sFile->ptr() && pEii->sFunction->ptr() )
				{
					try
					{
						char* pStr = NULL;
						wsprintf( szMsg, "%s::%s", pEii->sFile->ptr(), pEii->sFunction->ptr() );
						// Parse out the path
						int ch = '\\';
						pStr = strrchr( szMsg, ch );

						if( pStr )
						{
							pStr++; // dump the "\".
							pRk->Set( "function", pStr );
						}

						// Save the file info
						// wjr 1/9/07...
						wsprintf( szMsg, "%s", pEii->sFile->ptr() );
						pRk->Set( "file", szMsg );
						// ...wjr 1/9/07
			
					}
					catch(...)
					{
						ASSERT(0);
					}

				}
			}
			
			// Save the message
			pRk->Set( "message", pEii->cpkey );

			// Save the error code
			CWin32::GetSystemErrorMsg( pEii->dwCode, szMsg );
			pRk->Set( "code", szMsg );

			// wjr 1/9/07...
			// Save the line
			pRk->Set( "line", pEii->dwLine );

			// Save the severity
			pRk->Set( "severity", pEii->dwSeverity );

			// Save the raw time data
			pRk->Set( "timedata", pEii->dwTime );
			// ...wjr 1/9/07

		} // end if

	} // end while

	return TRUE;
}
Esempio n. 6
0
BOOL CStackReport::Profile(CReg *pReg, CStackTrace *pSt )
{_STT();
#ifndef ENABLE_STACK_PROFILE

	return FALSE;

#else

	CTlLocalLock ll( *pSt );
	if ( !ll.IsLocked() ) return FALSE;

	// Reset object
	pReg->Destroy();

	DWORD dwThreadId = GetCurrentThreadId();

	char szMsg[ 256 ] = "";
	CStackTrace::iterator it = NULL;
	CStackTrace::list *pList = pSt->GetList();
	while ( NULL != ( it = pList->next( it ) ) )
	{
		wsprintf( szMsg, "Thread %lu ( 0x%lx )", *it->key(), *it->key() );

		CRKey *pRk = pReg->GetKey( szMsg );
		if ( pRk )
		{
			// Flag if this is the current thread
			if ( dwThreadId == *it->key() ) pRk->Set( "current_thread", dwThreadId );
			
			// Save the thread id
			pRk->Set( "thread_id", *it->key() );

			TStrList< CStackTrace::CStack::SProfileItem > *pProfile = (*it)->GetProfile();
			if ( pProfile )
			{
				DWORD i = 0;
				TStrList< CStackTrace::CStack::SProfileItem >::iterator itPi = NULL;
				while ( NULL != ( itPi = pProfile->next( itPi ) ) )
				{
					// Save function name
					wsprintf( szMsg, "f_%lu", i );
					pRk->Set( szMsg, itPi->key() );

					// Save total time
					wsprintf( szMsg, "t_%lu", i );
					pRk->Set( szMsg, (double)( (double)(*itPi)->llTotalTime / (double)CHqTimer::GetTimerFrequency() ) );

					// Next index
					i++;

				} // end while

			} // end if

		} // end if

	} // end while

	return TRUE;
	
#endif
}
Esempio n. 7
0
BOOL CStackReport::History(CReg *pReg, CStackTrace *pSt )
{_STT();
#ifndef ENABLE_STACK_HISTORY

	return FALSE;

#else

	CTlLocalLock ll( *pSt );
	if ( !ll.IsLocked() ) return FALSE;

	// Reset object
	pReg->Destroy();

	DWORD dwThreadId = GetCurrentThreadId();

	char szMsg[ 256 ] = "";
	CStackTrace::iterator it = NULL;
	CStackTrace::list *pList = pSt->GetList();
	while ( NULL != ( it = pList->next( it ) ) )
	{
		wsprintf( szMsg, "Thread %lu ( 0x%lx )", *it->key(), *it->key() );

		CRKey *pRk = pReg->GetKey( szMsg );
		if ( pRk )
		{
			// Flag if this is the current thread
			if ( dwThreadId == *it->key() ) pRk->Set( "current_thread", dwThreadId );
			
			// Save the thread id
			pRk->Set( "thread_id", (DWORD)*it->key() );

			// Get stack information
			UINT uSize = (*it)->GetMaxHistory();
			UINT uPtr = (*it)->GetHistoryPtr();
			LPCTSTR *pHistory = (*it)->GetHistory();
#ifdef ENABLE_STACK_HISTORY_TIME
			LONGLONG *pHistoryTime = (*it)->GetHistoryTime(); // wjr 1/19/07
#endif

			// Is there anything in the history?
			if ( uSize )
			{
				// Save
				for ( UINT i = 0; i < uSize; i++ )
				{
					// Adjust pointer
					if ( uPtr ) uPtr--; else uPtr = uSize - 1;

					wsprintf( szMsg, "f_%04lu", i );// wjr 1/19/07

					if ( pHistory[ uPtr ] )
					{
						// wjr 1/19/07...
#ifdef ENABLE_STACK_HISTORY_TIME
						char szMsg2[ 256 ] = "";
						if( pHistoryTime[ uPtr ] )
							wsprintf( szMsg2, "%ld - %s", (unsigned long)pHistoryTime[ uPtr ], pHistory[ uPtr ] );
						else
							wsprintf( szMsg2, "%s", pHistory[ uPtr ] );// wjr 1/22/07

						pRk->Set( szMsg, szMsg2 );
#else
						pRk->Set( szMsg, pHistory[ uPtr ] );
#endif
						// ...wjr 1/19/07
					}

				} // end for

			} // end if

		} // end if

	} // end while

	return TRUE;

#endif

}
Esempio n. 8
0
BOOL CNetFile::HttpRequest(LPCTSTR pUrl, CRKey *pHeaders, CRKey *pData, LPCTSTR pMethod, LPCTSTR pLocal, BOOL bCloseFileAfterDownload, HWND hWndParent, DWORD dwUrlEncoding)
{_STT();
	// Lose previous file
	Destroy();

	// Downloading
	m_bUpload = FALSE;

	// Save parent window
	m_hWndParent = hWndParent;

	// Save close file status
	m_bCloseFileAfterDownload = bCloseFileAfterDownload;

	// Sanity check
	if ( pUrl == NULL || *pUrl == NULL ) return FALSE;

	// Are we downloading to file or ram?
	m_bMem = ( pLocal == NULL );

	{ // Copy the url
		
		char buf[ sizeof( m_szUrl ) ] = { 0 };
		DWORD size = sizeof( m_szUrl ) - 1;

		// Is it a local file?
		if ( GetFileAttributes( pUrl ) == MAXDWORD )
		{
			// Fix the url
			if ( InternetCanonicalizeUrl( pUrl, buf, &size, 0 ) )
			{	strcpy_sz( m_szUrl, buf ); }

			// Copy the url name
			else strcpy_sz( m_szUrl, pUrl );
		} // end if
		
		// Copy the local file name
		else strcpy_sz( m_szUrl, pUrl );

	} // end copy url	

	if ( !m_bMem )
	{
		// Where to download the file
		if ( pLocal != DOWNLOADTEMP ) { strcpy_sz( m_szLocal, pLocal ); }
		else CWinFile::CreateTemp( m_szLocal );	

		// Create a file to load data
		if ( !m_local.OpenNew( m_szLocal, GENERIC_READ | GENERIC_WRITE ) )
			return FALSE;
	} // end else
	
	// Set status	
	m_dwTransferStatus = NETFILE_DS_INITIALIZING;

	// Save request method
	if ( pMethod == NULL || *pMethod == 0 ) m_sMethod = "POST";
	else m_sMethod = pMethod;

	// Set data
	DWORD dwContentLength = 0;
	if ( pData != NULL )
	{	CPipe pipe;
		pData->EncodeUrl( &pipe, dwUrlEncoding );
		m_sData.copy( (LPCTSTR)pipe.GetBuffer(), pipe.GetBufferSize() );
		dwContentLength = pipe.GetBufferSize();
	} // end if

	// Set headers
	if ( strcmpi( m_sMethod, "GET" ) )
	{
		CRKey rkHeaders;
		if ( pHeaders != NULL ) rkHeaders.Copy( pHeaders );
		
		rkHeaders.Set( "Content-Type", "application/x-www-form-urlencoded" );
		rkHeaders.Set( "Content-Length", dwContentLength );

		CPipe pipe;
		rkHeaders.EncodeHttpHeaders( &pipe );
		m_sHeaders.copy( (LPCTSTR)pipe.GetBuffer(), pipe.GetBufferSize() );

	} // end if

	// Create a thread to download the file
	if ( !StartThread() )
	{	Destroy();
		m_dwTransferStatus = NETFILE_DS_ERROR;		
		return FALSE;
	} // end if

	return TRUE;
}