Ejemplo n.º 1
0
CLiveItem* CGraphListDlg::PrepareItem(CGraphItem* pItem)
{
	CLiveItem* pLive = new CLiveItem( LIST_COLUMNS, reinterpret_cast< DWORD_PTR>( pItem ) );
	pLive->SetImage( 0, I_IMAGECALLBACK );

	pLive->Set( 0, pItem->m_sName );

	return pLive;
}
Ejemplo n.º 2
0
BOOL CDownloadReviewDlg::OnInitDialog() 
{
	CSkinDialog::OnInitDialog();

	CRect rcList;
	m_wndReviews.GetClientRect( &rcList );
	rcList.right -= GetSystemMetrics( SM_CXVSCROLL );

	CoolInterface.SetImageListTo( m_wndReviews, LVSIL_SMALL );
	m_wndReviews.InsertColumn( 0, _T("User"), LVCFMT_LEFT, 100, -1 );
	m_wndReviews.InsertColumn( 1, _T("Rating"), LVCFMT_CENTER, 90, 0 );
	m_wndReviews.InsertColumn( 2, _T("Comments"), LVCFMT_CENTER, rcList.right- 100 - 80, 1 );
	m_wndReviews.InsertColumn( 3, _T("Order"), LVCFMT_CENTER, 0, 2 );
	Skin.Translate( _T("CReviewList"), m_wndReviews.GetHeaderCtrl() );
	
	m_wndReviews.SendMessage( LVM_SETEXTENDEDLISTVIEWSTYLE,
		LVS_EX_FULLROWSELECT|LVS_EX_LABELTIP, LVS_EX_FULLROWSELECT|LVS_EX_LABELTIP );
	m_wndReviews.EnableToolTips();
	
	// Sort by order added- first at the top
	CLiveList::Sort( &m_wndReviews, 3, FALSE );
	CLiveList::Sort( &m_wndReviews, 3, FALSE );


	CLiveList pReviews( 4 );
	int nIndex = 1;
	// Lock while we're loading the list. (In case the download is destroyed)
	CSingleLock pLock( &Transfers.m_pSection, TRUE );
	
	if ( ! m_pDownload ) return FALSE;

	m_sReviewFileName = m_pDownload->m_sName;

	CDownloadReview* pReview = m_pDownload->GetFirstReview();

	while ( pReview )
	{
		CLiveItem* pItem = pReviews.Add( pReview );
	
		// Client picture
		// Note: We don't have pictures yet. Currently, it uses a star for a G2 
		// review, and a little person for everyone else
		switch ( pReview->m_nUserPicture )
		{
		case 0:
			pItem->SetImage( 0, CoolInterface.ImageForID( ID_TOOLS_WIZARD ) );
			break;
		case 1:
			pItem->SetImage( 0, CoolInterface.ImageForID( ID_TOOLS_PROFILE ) );
			break;
		case 2:
			pItem->SetImage( 0, CoolInterface.ImageForID( ID_TOOLS_WIZARD ) );
			break;
		case 3:
			pItem->SetImage( 0, CoolInterface.ImageForID( ID_TOOLS_PROFILE ) );
			break;
		default:
			pItem->SetImage( 0, CoolInterface.ImageForID( ID_TOOLS_PROFILE ) );
		}
		
		pItem->Set( 0, pReview->m_sUserName );

		int nRating = min( pReview->m_nFileRating, 6 );
		nRating = max ( nRating, 0 );
		CString strRating;
		LoadString( strRating, IDS_RATING_NORATING + nRating );
		pItem->Set( 1, strRating );

		
		pItem->Set( 2, pReview->m_sFileComments );
		pItem->Format( 3, _T("%i"), nIndex );
		

		nIndex++;
		pReview = pReview->m_pNext;
	}

	pLock.Unlock();

	//m_wndReviews.SetFont( &theApp.m_gdiFontBold );

	pReviews.Apply( &m_wndReviews, TRUE );

	// Set window icon
	SkinMe( NULL, IDR_MEDIAFRAME );

	UpdateData( FALSE );
	
	return TRUE;
}
Ejemplo n.º 3
0
void CSearchMonitorWnd::OnQuerySearch(const CQuerySearch* pSearch)
{
	if ( m_bPaused || m_hWnd == NULL )
		return;

	CSingleLock pLock( &m_pSection );
	if ( ! pLock.Lock( 250 ) )
		return;

	if ( m_bPaused )
		return;

	CLiveItem* pItem = new CLiveItem( 4, NULL );

	CString strSearch = pSearch->m_sSearch;
	CString strSchema;
	CString strURN;
	CString strNode;
	if ( pSearch->m_pEndpoint.sin_addr.s_addr )
		strNode.Format( _T("%hs:%u"),
			inet_ntoa( pSearch->m_pEndpoint.sin_addr ),
			ntohs( pSearch->m_pEndpoint.sin_port ) );

	if ( pSearch->m_oSHA1 && pSearch->m_oTiger )
	{
		strURN	= _T("bitprint:")
				+ pSearch->m_oSHA1.toString()
				+ '.'
				+ pSearch->m_oTiger.toString();
	}
	else if ( pSearch->m_oTiger )
	{
		strURN = pSearch->m_oTiger.toShortUrn();
	}
	else if ( pSearch->m_oSHA1 )
	{
		strURN = pSearch->m_oSHA1.toShortUrn();
	}
	else if ( pSearch->m_oED2K )
	{
		strURN = pSearch->m_oED2K.toShortUrn();
	}
	else if ( pSearch->m_oBTH )
	{
		strURN = pSearch->m_oBTH.toShortUrn();
	}
	else if ( pSearch->m_oMD5 )
	{
		strURN = pSearch->m_oMD5.toShortUrn();
	}
	else
		strURN = _T("None");

	if ( pSearch->m_bWhatsNew )
		strSearch = _T("What's New?");

	if ( pSearch->m_pXML )
	{
		strSearch += _T('«');
		strSearch += pSearch->m_pXML->GetRecursiveWords();
		strSearch += _T('»');
	}

	if ( pSearch->m_pSchema )
		strSchema = pSearch->m_pSchema->m_sTitle;
	else
		strSchema = _T("None");

	pItem->Set( 0, strSearch );
	pItem->Set( 1, strURN );
	pItem->Set( 2, strSchema );
	pItem->Set( 3, strNode );
		
	m_pQueue.AddTail( pItem );
}
Ejemplo n.º 4
0
void CHostCacheWnd::Update(BOOL bForce)
{
	if ( !bForce ) 
		if ( !m_bAllowUpdates ) return;

	CSingleLock pLock( &Network.m_pSection );
	if ( ! pLock.Lock( 50 ) ) return;
	
	m_wndList.ModifyStyle( WS_VISIBLE, 0 );
	
	CLiveList pLiveList( 8 );
	
	PROTOCOLID nEffective = m_nMode ? m_nMode : PROTOCOL_G2;

	CHostCacheList* pCache = HostCache.ForProtocol( nEffective );
	
	m_nCookie = pCache->m_nCookie;
	int nProtocolRev = m_gdiImageList.GetImageCount() - 1;
	
	for ( CHostCacheHost* pHost = pCache->GetNewest() ; pHost ; pHost = pHost->m_pPrevTime )
	{
		// cancel update if mouse moves ouside window or user right-clicks
		// do not break if different cache window button pressed
		if ( !m_bAllowUpdates && !bForce ) break;
		if ( m_nMode == PROTOCOL_NULL )
		{
			if ( HubHorizonPool.Find( &pHost->m_pAddress ) == NULL ) continue;
		}
		
		CLiveItem* pItem = pLiveList.Add( pHost );
		
		pItem->m_nImage			= theApp.m_bRTL ? nProtocolRev - pHost->m_nProtocol : pHost->m_nProtocol;
		pItem->m_nMaskOverlay	= pHost->m_bPriority;
		
		pItem->Set( 0, CString( inet_ntoa( pHost->m_pAddress ) ) );
		pItem->Format( 1, _T("%hu"), pHost->m_nPort );
		
#ifdef _DEBUG
		pItem->Format( 2, _T("K:%u A:%u Q:%u"),
			pHost->m_nKeyValue, pHost->m_tAck, pHost->m_tQuery );
#else
		if ( pHost->m_pVendor )
			pItem->Set( 2, pHost->m_pVendor->m_sName );
		else if ( pHost->m_nProtocol == PROTOCOL_G2 )
			pItem->Set( 2, _T("(Gnutella2)") );
		else if ( pHost->m_nProtocol == PROTOCOL_ED2K )
			pItem->Set( 2, _T("(eDonkey Server)") );
#endif
		
		CTime pTime( (time_t)pHost->m_tSeen );
		pItem->Set( 3, pTime.Format( _T("%Y-%m-%d %H:%M:%S") ) );
		
		pItem->Set( 4, pHost->m_sName );
		pItem->Set( 5, pHost->m_sDescription );
		
		if ( pHost->m_nUserCount ) pItem->Format( 6, _T("%u"), pHost->m_nUserCount );
		if ( pHost->m_nUserLimit ) pItem->Format( 7, _T("%u"), pHost->m_nUserLimit );
	}
	
	if ( !m_bAllowUpdates && !bForce ) return;
	pLiveList.Apply( &m_wndList, TRUE );
	m_wndList.ShowWindow( SW_SHOW );

	tLastUpdate = GetTickCount();				// Update timer
}
Ejemplo n.º 5
0
void CSchedulerWnd::Update(int nColumn, BOOL bSort)
{
	HRESULT hr;

	CComPtr< IEnumWorkItems > pEnum;
	hr = m_pScheduler->Enum( &pEnum );
	if ( FAILED( hr ) )
		return;

	CLiveList pLiveList( 6 );

	int nCount = 1;
	for ( ; ; )
	{
		LPWSTR* pszTaskName = NULL;
		hr = pEnum->Next( 1, &pszTaskName, NULL );
		if ( hr != S_OK )
			// No tasks left
			break;
		CString sTaskName = *pszTaskName;
		CoTaskMemFree( pszTaskName );

		CString sVendor = sTaskName.SpanExcluding( _T(".") );
		if ( sVendor.Compare( CLIENT_NAME_T ) != 0 )
			// Wrong name
			continue;
		DWORD_PTR nNumber = _tstoi( sTaskName.Mid( sVendor.GetLength() + 1 ) );

		CComPtr< ITask > pTask;
		hr = m_pScheduler->Activate( sTaskName, IID_ITask, (IUnknown**)&pTask );
		if ( FAILED( hr ) )
			// Can't open task
			continue;

		DWORD nFlags = 0;
		hr = pTask->GetFlags( &nFlags );
		BOOL bActive = ( ( nFlags & TASK_FLAG_DISABLED ) != TASK_FLAG_DISABLED );

		HRESULT hrStatus = S_OK;
		hr = pTask->GetStatus( &hrStatus );

		CString sTriggerString;
		LPWSTR szTriggerString = NULL;
		hr = pTask->GetTriggerString( 0, &szTriggerString );
		if ( hr == S_OK )
		{
			sTriggerString = szTriggerString;
			CoTaskMemFree( szTriggerString );
		}

		CString strDate, strTime;
		SYSTEMTIME pTime = {};
		hr = pTask->GetNextRunTime( &pTime );
		if ( hr == S_OK )
		{
			GetDateFormat( LOCALE_USER_DEFAULT, DATE_SHORTDATE, &pTime, NULL, strDate.GetBuffer( 64 ), 64 );
			GetTimeFormat( LOCALE_USER_DEFAULT, TIME_NOSECONDS, &pTime, NULL, strTime.GetBuffer( 64 ), 64 );
			strDate.ReleaseBuffer();
			strTime.ReleaseBuffer();
		}
		else if ( hr == SCHED_S_TASK_DISABLED )
			bActive = FALSE;

		CString sStatus;
		DWORD nExitCode = 0;
		hr = pTask->GetExitCode( &nExitCode );
		if ( SUCCEEDED( hr ) )
		{
			sStatus.Format( _T("0x%08X"), nExitCode );
		}

		int nAction = -1;
		LPWSTR szParams = NULL;
		hr = pTask->GetParameters( &szParams );
		if ( SUCCEEDED( hr ) )
		{
			CString sParams = szParams;
			CoTaskMemFree( szParams );

			int nPos = sParams.Find( _T("task") );
			if ( nPos != -1 )
				nAction = _tstoi( sParams.Mid( nPos + 4 ) );
			else
				nAction = SYSTEM_START;
		}

		CString sComment;
		LPWSTR szComment = NULL;
		hr = pTask->GetComment( &szComment );
		if ( SUCCEEDED( hr ) )
		{
			sComment = szComment;
			CoTaskMemFree( szComment );
		}

		//Adding tasks we got from Scheduler to temp list and getting a handle
		//to modify their properties according to scheduler item.
		CLiveItem* pItem = pLiveList.Add( nNumber );

		if ( ( nFlags & TASK_FLAG_DISABLED ) != TASK_FLAG_DISABLED )
			pItem->SetImage( 0, SCHEDULE_ITEM_ACTIVE );
		else 
			pItem->SetImage( 0, SCHEDULE_ITEM_INACTIVE );

		//Action column
		switch ( nAction )
		{
		case BANDWIDTH_FULLSPEED:
			pItem->Set( 0, LoadString( IDS_SCHEDULER_BANDWIDTH_FULLSPEED ) );
			break;
		case BANDWIDTH_REDUCEDSPEED:
			pItem->Set( 0, LoadString( IDS_SCHEDULER_BANDWIDTH_REDUCEDSPEED ) );
			break;
		case BANDWIDTH_STOP:
			pItem->Set( 0, LoadString( IDS_SCHEDULER_BANDWIDTH_STOP ) );
			break;
		case SYSTEM_DIALUP_DC:
			pItem->Set( 0, LoadString( IDS_SCHEDULER_SYSTEM_DIALUP_DC ) );
			break;
		case SYSTEM_EXIT:
			pItem->Set( 0, LoadString( IDS_SCHEDULER_SYSTEM_EXIT ) );
			break;
		case SYSTEM_SHUTDOWN:
			pItem->Set( 0, LoadString( IDS_SCHEDULER_SYSTEM_SHUTDOWN ) );
			break;
		case SYSTEM_START:
			pItem->Set( 0, LoadString( IDS_SCHEDULER_SYSTEM_START ) );
			break;
		}

		// Date column
		pItem->Set( 1, sTriggerString );

		// Time column
		pItem->Set( 2, strDate + _T(" ") + strTime );

		// Active column
		if ( bActive )
		{
			switch ( hrStatus )
			{
			case SCHED_S_TASK_NO_MORE_RUNS:
				pItem->Set( 3, LoadString( IDS_SCHEDULER_TASK_DONE ) );
				break;
			case SCHED_S_TASK_RUNNING:
				pItem->Set( 3, LoadString( IDS_SCHEDULER_TASK_ACTIVE ) );
				break;
			default:
				pItem->Set( 3, LoadString( IDS_SCHEDULER_TASK_WAITING ) );
			}
		}
		else
			pItem->Set( 3, LoadString( IDS_SCHEDULER_TASK_INACTIVE ) );

		// Status column 
		pItem->Set( 4, sStatus );

		//Description column
		pItem->Set( 5, sComment );

		++nCount;
	}

	// In case scheduler gave nothing
	if ( nCount == 1 )
	{
		CLiveItem* pDefault = pLiveList.Add( (DWORD_PTR)0 );
		pDefault->Set( 0, LoadString( IDS_SCHEDULER_NOTASK ) );
		pDefault->SetImage( 0, SCHEDULE_NO_ITEM );
	}

	if ( nColumn >= 0 )
	{
		SetWindowLongPtr( m_wndList.GetSafeHwnd(), GWLP_USERDATA, 0 - nColumn - 1 );
	}

	pLiveList.Apply( &m_wndList, bSort );	//Putting items in the main list

	tLastUpdate = GetTickCount();	// Update time after it's done doing its work
}