Exemple #1
0
CCircuitry* CNeighbour::ConnectTo(LPCTSTR xUserId, DWORD nTimeOut)
{
	CSingleLock pLock( &m_pSection, TRUE );
	
	CCircuitry* pChannel = FindChannel( xUserId );
	if ( pChannel ) return pChannel;
	
	NETRESOURCE ns;
	
	ns.dwScope = RESOURCE_CONNECTED;   
	ns.dwType = RESOURCETYPE_ANY; 
	ns.dwDisplayType = RESOURCEDISPLAYTYPE_GENERIC;
	ns.dwUsage = RESOURCEUSAGE_CONNECTABLE;
	
	ns.lpRemoteName	= Settings.Centric.Remote.GetBuffer(0);
	ns.lpLocalName = NULL;
	ns.lpProvider = NULL;
	
	WNetAddConnection2( &ns, Settings.Centric.Password, Settings.Centric.UserId, 0 );
	
	if ( ! WaitNamedPipe( Settings.Centric.Remote, nTimeOut ) ) return NULL;
	
	pChannel = SetChannel( new CCircuitry( xUserId ) );
	pChannel->ConnectTo( Settings.Centric.Remote, nTimeOut  );
	
	pChannel->SendPacket( new CBindPacket( xUserId, "" ) );
	
	Connect(); return pChannel;
}
void CUploadsWnd::OnUploadsClear()
{
	CSingleLock pLock( &Transfers.m_pSection, TRUE );
	CList<CUploadFile*> pList;

	for ( POSITION pos = UploadFiles.GetIterator() ; pos ; )
	{
		CUploadFile* pFile = UploadFiles.GetNext( pos );
		if ( IsSelected( pFile ) ) pList.AddTail( pFile );
	}

	while ( ! pList.IsEmpty() )
	{
		CUploadFile* pFile = pList.RemoveHead();

		if ( UploadFiles.Check( pFile ) )
		{
			CUploadTransfer* pUpload = pFile->GetActive();

			if ( pUpload != NULL && pUpload->m_nProtocol == PROTOCOL_ED2K && pUpload->m_nState != upsNull )
			{
				CString strFormat, strMessage;
				LoadString( strFormat, IDS_UPLOAD_CANCEL_ED2K );
				strMessage.Format( strFormat, (LPCTSTR)pUpload->m_sFileName );
				pLock.Unlock();
				UINT nResp = AfxMessageBox( strMessage, MB_ICONQUESTION|MB_YESNOCANCEL|MB_DEFBUTTON2 );
				pLock.Lock();
				if ( nResp == IDCANCEL ) break;
				if ( nResp != IDYES || ! UploadFiles.Check( pFile ) ) continue;
			}

			pFile->Remove();
		}
	}
}
void CUploadsWnd::OnSecurityBan()
{
	CSingleLock pLock( &Transfers.m_pSection, TRUE );
	CList<CUploadFile*> pList;

	for ( POSITION pos = UploadFiles.GetIterator() ; pos ; )
	{
		CUploadFile* pFile = UploadFiles.GetNext( pos );
		if ( IsSelected( pFile ) ) pList.AddTail( pFile );
	}

	while ( ! pList.IsEmpty() )
	{
		CUploadFile* pFile = pList.RemoveHead();

		if ( UploadFiles.Check( pFile ) && pFile->GetActive() != NULL )
		{
			CUploadTransfer* pUpload = pFile->GetActive();

			IN_ADDR pAddress = pUpload->m_pHost.sin_addr;
			pUpload->Remove( FALSE );
			pLock.Unlock();
			Security.Ban( &pAddress, banSession );
			pLock.Lock();
		}
	}
}
void CLibraryFileView::OnUpdateLibraryShared(CCmdUI* pCmdUI)
{
	if ( GetSelectedCount() < 1 )
	{
		pCmdUI->Enable( FALSE );
		pCmdUI->SetCheck( FALSE );
		return;
	}

	TRISTATE bShared = TRI_UNKNOWN;

	CSingleLock pLock( &Library.m_pSection );
	if ( pLock.Lock( 100 ) )
	{
		POSITION posSel = StartSelectedFileLoop();
		while ( CLibraryFile* pFile = GetNextSelectedFile( posSel ) )
		{
			if ( bShared == TRI_UNKNOWN )
			{
				bShared = pFile->IsShared() ? TRI_TRUE : TRI_FALSE;
			}
			else if ( ( bShared == TRI_TRUE ) != pFile->IsShared() )
			{
				pCmdUI->Enable( FALSE );
				return;
			}
		}
		pLock.Unlock();
	}

	pCmdUI->Enable( TRUE );
	pCmdUI->SetCheck( bShared == TRI_TRUE );
}
void CLibraryFileView::OnUpdateMusicBrainzLookup(CCmdUI* pCmdUI)
{
	if ( m_bGhostFolder || GetSelectedCount() != 1 || m_bRequestingService )
	{
		pCmdUI->Enable( FALSE );
		return;
	}

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

	CLibraryFile* pFile = GetSelectedFile();
	if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) || pFile->m_pMetadata == NULL )
	{
		pCmdUI->Enable( FALSE );
		return;
	}

	CMetaList* pMetaList = new CMetaList();
	pMetaList->Setup( pFile->m_pSchema, FALSE );
	pMetaList->Combine( pFile->m_pMetadata );

	pLock.Unlock();

	pCmdUI->Enable( pMetaList->IsMusicBrainz() );

	delete pMetaList;
}
void CSearchMonitorWnd::OnTimer(UINT_PTR nIDEvent) 
{
	if ( nIDEvent != 2 ) return;

	BOOL bScroll = m_wndList.GetTopIndex() + m_wndList.GetCountPerPage() >= m_wndList.GetItemCount();

	for (;;)
	{
		CLiveItem* pItem;

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

			if ( m_pQueue.GetCount() == 0 )
				break;

			pItem = m_pQueue.RemoveHead();
		}

		if ( (DWORD)m_wndList.GetItemCount() >= Settings.Search.MonitorQueue && Settings.Search.MonitorQueue > 0 )
		{
			m_wndList.DeleteItem( 0 );
		}

		/*int nItem =*/ pItem->Add( &m_wndList, -1, 4 );

		delete pItem;
	}

	if ( bScroll ) m_wndList.EnsureVisible( m_wndList.GetItemCount() - 1, FALSE );
}
void CLibraryFileView::OnLibraryURL()
{
	CSingleLock pLock( &Library.m_pSection, TRUE );

	if ( GetSelectedCount() == 1 )
	{
		CLibraryFile* pFile = GetSelectedFile();
		if ( ! pFile ) return;

		CURLCopyDlg dlg;

		dlg.Add( pFile );

		pLock.Unlock();

		dlg.DoModal();
	}
	else
	{
		CURLExportDlg dlg;

		POSITION posSel = StartSelectedFileLoop();
		while ( CLibraryFile* pFile = GetNextSelectedFile( posSel ) )
		{
			dlg.Add( pFile );
		}

		pLock.Unlock();

		dlg.DoModal();
	}
}
Exemple #8
0
void CSearchWnd::OnFilters(UINT nID)
{
    if ( nID < 3000 ) return;
    const int nFilter = nID - 3000;

    {
        CQuickLock pLock( m_pMatches->m_pSection );

        if ( (DWORD)nFilter > m_pMatches->m_pResultFilters->m_nFilters - 1 ) return;

        m_pMatches->m_bFilterBusy		= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_bFilterBusy;
        m_pMatches->m_bFilterPush		= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_bFilterPush;
        m_pMatches->m_bFilterUnstable	= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_bFilterUnstable;
        m_pMatches->m_bFilterReject		= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_bFilterReject;
        m_pMatches->m_bFilterLocal		= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_bFilterLocal;
        m_pMatches->m_bFilterBogus		= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_bFilterBogus;
        m_pMatches->m_bFilterDRM		= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_bFilterDRM;
        m_pMatches->m_bFilterAdult		= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_bFilterAdult;
        m_pMatches->m_bFilterSuspicious = m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_bFilterSuspicious;
        m_pMatches->m_nFilterMinSize	= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_nFilterMinSize;
        m_pMatches->m_nFilterMaxSize	= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_nFilterMaxSize;
        m_pMatches->m_nFilterSources	= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_nFilterSources;
        m_pMatches->m_sFilter			= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_sFilter;

        m_pMatches->Filter();
    }

    Invalidate();
}
void CDownloadGroups::CreateDefault()
{
	CSingleLock pLock( &m_pSection, TRUE );

	CDownloadGroup* pGroup	= GetSuperGroup();

	pGroup = Add( _T("Audio") );
	pGroup->AddFilter( _T(".mp3") );
	pGroup->AddFilter( _T(".ogg") );
	pGroup->AddFilter( _T(".wav") );
	pGroup->AddFilter( _T(".wma") );
	pGroup->SetSchema( CSchema::uriMusicAlbum );

	pGroup = Add( _T("Video") );
	pGroup->AddFilter( _T(".asf") );
	pGroup->AddFilter( _T(".avi") );
	pGroup->AddFilter( _T(".mov") );
	pGroup->AddFilter( _T(".mpg") );
	pGroup->AddFilter( _T(".mpeg") );
	pGroup->AddFilter( _T(".ogm") );
	pGroup->AddFilter( _T(".wmv") );
	pGroup->SetSchema( CSchema::uriVideo );

	pGroup = Add( _T("BitTorrent") );
	pGroup->AddFilter( _T("torrent") );
	pGroup->SetSchema( CSchema::uriROM );
}
Exemple #10
0
void CHashDatabase::Close()
{
	CSingleLock pLock( &m_pSection, TRUE );

	delete [] m_pIndex;

	if ( m_pFile.m_hFile != CFile::hFileNull )
	{
		try
		{
			m_pFile.Close();
		}
		catch ( CException* pException )
		{
			m_pFile.Abort();
			pException->Delete();
		}
	}

	m_bOpen		= FALSE;
	m_nOffset	= 0;
	m_pIndex	= NULL;
	m_nIndex	= 0;
	m_nBuffer	= 0;
}
Exemple #11
0
void CSearchWnd::OnSearchStop()
{
    CQuickLock pLock( m_pMatches->m_pSection );

    if ( ( GetAsyncKeyState( VK_SHIFT ) & 0x8000 ) == 0x8000 )
    {
        if ( ! m_bPaused && ! m_bWaitMore )
        {
            // Pause search
            if ( ! empty() )
            {
                m_oSearches.back()->SetActive( FALSE );
                m_bWaitMore = TRUE;
                m_bUpdate = TRUE;
                return;
            }
        }
    }

    for ( iterator pManaged = begin() ; pManaged != end() ; ++pManaged )
    {
        (*pManaged)->Stop();
        (*pManaged)->m_bReceive = FALSE;
    }

    m_bPaused = TRUE;

    m_wndPanel.Enable();
    UpdateMessages();

    SetModified();
}
Exemple #12
0
CTransferFile* CTransferFiles::Open(LPCTSTR pszFile, BOOL bWrite)
{
	CSingleLock pLock( &m_pSection, TRUE );

	CTransferFile* pFile = NULL;
	if ( m_pMap.Lookup( pszFile, pFile ) )
	{
		if ( bWrite && ! pFile->EnsureWrite() )
			return NULL;
	
		pFile->AddRef();
	}
	else
	{
		pFile = new CTransferFile( pszFile );
		if ( ! pFile->Open( bWrite ) )
		{
			DWORD dwError = GetLastError();
			pFile->Release();
			SetLastError( dwError );
			return NULL;
		}

		m_pMap.SetAt( pFile->m_sPath, pFile );

		TRACE( "Transfer Files : Opened \"%s\" [%s]\n", (LPCSTR)CT2A( pszFile ), ( bWrite ? "write" : "read" ) );
	}

	return pFile;
}
Exemple #13
0
void CTransferFiles::QueueDeferred(CTransferFile* pFile)
{
	CSingleLock pLock( &m_pSection, TRUE );

	if ( NULL == m_pDeferred.Find( pFile ) )
		m_pDeferred.AddTail( pFile );
}
Exemple #14
0
BOOL CNeighbour::OnRun()
{
	CSingleLock pLock( &m_pSection );
	
	while ( m_bThread )
	{
		WaitForSingleObject( m_pWakeup, 50 );
		
		if ( ! m_bThread ) break;
		if ( pLock.Lock( 250 ) )
		{
//TRACE("%i->>>>>>>>> CNeighbour AcceptCircuitry in\n", GetTickCount());
			AcceptCircuitry();
//TRACE("%i->>>>>>>>> CNeighbour AcceptCircuitry out.......\n", GetTickCount());
			pLock.Unlock();
		}
		
		if ( ! m_bThread ) break;
		if ( pLock.Lock( 250 ) )
		{
//TRACE("%i->>>>>>>>> CNeighbour in\n", GetTickCount());
			RunNeighbours();
//TRACE("%i->>>>>>>>> CNeighbour out.......\n", GetTickCount());
			pLock.Unlock();
		}
	}
	
	return TRUE;
}
Exemple #15
0
void CRemote::PageNewSearch()
{
	if ( CheckCookie() ) return;

	CMainWnd* pMainWnd = (CMainWnd*)theApp.m_pMainWnd;
	if ( pMainWnd == NULL || ! pMainWnd->IsKindOf( RUNTIME_CLASS(CMainWnd) ) ) return;

	CSingleLock pLock( &theApp.m_pSection );
	if ( ! SafeLock( pLock ) ) return;

	const CString strSearch = GetKey( L"search" );
	const CString strSchema = GetKey( L"schema" );

	if ( strSearch.IsEmpty() || ( ! strSchema.IsEmpty() && SchemaCache.Get( strSchema ) == NULL ) )
	{
		m_sRedirect = L"home";
		return;
	}

	CQuerySearchPtr pSearch	= new CQuerySearch();
	pSearch->m_sSearch		= strSearch;
	pSearch->m_pSchema		= SchemaCache.Get( strSchema );

	CString strURI;
	if ( pSearch->m_pSchema != NULL )
		strURI = pSearch->m_pSchema->GetURI();

	Settings.Search.LastSchemaURI = strURI;

	pMainWnd->PostMessage( WM_OPENSEARCH, (WPARAM)pSearch.Detach() );
	pLock.Unlock();
	Sleep( 500 );

	m_sRedirect = L"search";
}
// Takes a protocol, like Gnutella, a state, like connecting, and a node connection type, like we are both ultrapeers
// Counts the number of neighbours in the list that match these criteria, pass -1 to count them all
DWORD CNeighboursBase::GetCount(PROTOCOLID nProtocol, int nState, int nNodeType) const
{
	DWORD nCount = 0;

	CSingleLock pLock( &Network.m_pSection, FALSE );
	if ( pLock.Lock( 200 ) )
	{
		for ( POSITION pos = GetIterator() ; pos ; )
		{
			CNeighbour* pNeighbour = GetNext( pos );

			// If this neighbour has the protocol we are looking for, or nProtocl is negative to count them all
			if ( nProtocol == PROTOCOL_ANY || nProtocol == pNeighbour->m_nProtocol )
			{
				// If this neighbour is currently in the state we are looking for, or nState is negative to count them all
				if ( nState < 0 || nState == pNeighbour->m_nState )
				{
					// If this neighbour is in the ultra or leaf role we are looking for, or nNodeType is null to count them all
					if ( nNodeType < 0 || nNodeType == pNeighbour->m_nNodeType )
						nCount++;
				}
			}
		}
	}

	return nCount;
}
void CDownloadMonitorDlg::OnDestroy()
{
	KillTimer( 1 );

	if ( m_pDownload != NULL )
	{
		CDownload* pDownload = m_pDownload;
		m_pDownload = NULL;

		CSingleLock pLock( &Transfers.m_pSection );
		if ( pLock.Lock( 250 ) )
		{
			if ( Downloads.Check( pDownload ) )
				pDownload->m_pMonitorWnd = NULL;
		}
	}

	if ( m_bTray )
	{
		Shell_NotifyIcon( NIM_DELETE, &m_pTray );
		m_bTray = FALSE;
	}

	CSkinDialog::OnDestroy();
}
Exemple #18
0
bool CLocalSearch::ExecutePartialFiles(INT_PTR nMaximum, INT_PTR& nHits)
{
	CSingleLock pLock( &Transfers.m_pSection );
	if ( ! pLock.Lock( 250 ) )
		return false;

	if ( ! m_pSearch || ! m_pSearch->m_bWantPFS || m_nProtocol != PROTOCOL_G2 )
		// Browse request, or no partials requested, or non Gnutella 2 request
		return true;

	CList< CDownload* > oFilesInPacket;

	for ( POSITION pos = Downloads.GetIterator() ;
		pos && ( ! nMaximum || ( nHits + oFilesInPacket.GetCount() < nMaximum ) ); )
	{
		CDownload* pDownload = Downloads.GetNext( pos );

		if ( IsValidForHit( pDownload ) )
		{
			oFilesInPacket.AddTail( pDownload );
		}
	}

	SendHits( oFilesInPacket );

	nHits += oFilesInPacket.GetCount();

	return true;
}
void CLibraryFileView::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
{
	GetToolTip()->Hide();

	CStringList oFiles;
	{
		CQuickLock pLock( Library.m_pSection );
		POSITION posSel = StartSelectedFileLoop();
		while ( CLibraryFile* pFile = GetNextSelectedFile( posSel ) )
		{
			oFiles.AddTail( pFile->GetPath() );
		}
	}

	if ( oFiles.GetCount() == 0 )
	{
		// No files were selected, try folder itself
		if ( CLibraryTreeItem* pRoot = GetFolderSelection() )
		{
			if ( pRoot->m_pPhysical )
				oFiles.AddTail( pRoot->m_pPhysical->m_sPath );
		}
	}

	if ( point.x == -1 && point.y == -1 )	// Keyboard fix
		ClientToScreen( &point );

	CString strName( m_pszToolBar );
//	strName += Settings.Library.ShowVirtual ? _T(".Virtual") : _T(".Physical");		// For now, CLibraryFileView.Virtual = CLibraryFileView.Physical

	Skin.TrackPopupMenu( strName, point, ID_LIBRARY_LAUNCH, oFiles );
}
void CBaseMatchWnd::OnSearchForSeries() 
{
	CSingleLock pLock( &m_pMatches->m_pSection, TRUE );
	CRelatedSearch pSearch( m_pMatches->GetSelectedFile( TRUE ) );
	pLock.Unlock();
	pSearch.RunSearchForSeries();
}
void CLibraryFileView::OnLibraryCreateTorrent()
{
	if ( GetSelectedCount() == 1 && Settings.BitTorrent.DefaultTracker.GetLength() > 10 )
	{
		CSingleLock pLock( &Library.m_pSection, TRUE );

		if ( CLibraryFile* pFile = GetSelectedFile() )
		{
			CString strPath = pFile->GetPath();
			pLock.Unlock();

			if ( ! strPath.IsEmpty() )
			{
				CString strCommandLine = _T(" -sourcefile \"") + strPath + _T("\" -destination \"") +
					Settings.Downloads.TorrentPath + _T("\" -tracker \"") + Settings.BitTorrent.DefaultTracker + _T("\"");

				ShellExecute( GetSafeHwnd(), _T("open"), Settings.BitTorrent.TorrentCreatorPath, strCommandLine, NULL, SW_SHOWNORMAL );

				return;
			}
		}
	}

	ShellExecute( GetSafeHwnd(), _T("open"), Settings.BitTorrent.TorrentCreatorPath, NULL, NULL, SW_SHOWNORMAL );
}
BOOL CNetwork::AsyncResolve(LPCTSTR pszAddress, WORD nPort, PROTOCOLID nProtocol, BYTE nCommand)
{
	CSingleLock pLock( &m_pSection );
	if ( ! pLock.Lock( 250 ) ) return FALSE;
	
	BYTE* pResolve = (BYTE*)malloc( MAXGETHOSTSTRUCT + 8 );
	
	USES_CONVERSION;
	
	HANDLE hAsync = WSAAsyncGetHostByName( AfxGetMainWnd()->GetSafeHwnd(), WM_WINSOCK,
		T2CA(pszAddress), (LPSTR)pResolve + 8, MAXGETHOSTSTRUCT );
	
	if ( hAsync != NULL )
	{
		*((CString**)&pResolve[0])	= new CString( pszAddress );
		*((WORD*)&pResolve[4])		= nPort;
		*((BYTE*)&pResolve[6])		= nProtocol;
		*((BYTE*)&pResolve[7])		= nCommand;
		
		m_pLookups.SetAt( (LPVOID)hAsync, (LPVOID)pResolve );
		return TRUE;
	}
	else
	{
		free( pResolve );
		return FALSE;
	}
}
void CLibraryFileView::OnLibraryBitziDownload()
{
	GetFrame()->SetDynamicBar( NULL );

	if ( ! Settings.WebServices.BitziOkay )
	{
		if ( MsgBox( IDS_LIBRARY_BITZI_MESSAGE, MB_ICONQUESTION|MB_YESNO ) != IDYES ) return;
		Settings.WebServices.BitziOkay = true;
		Settings.Save();
	}

	CBitziDownloadDlg dlg;

	CSingleLock pLock( &Library.m_pSection, TRUE );

	POSITION posSel = StartSelectedFileLoop();
	while ( CLibraryFile* pFile = GetNextSelectedFile( posSel ) )
	{
		if ( pFile->m_oSHA1 )
			dlg.AddFile( pFile->m_nIndex );
	}

	pLock.Unlock();

	dlg.DoModal();
}
void CNetwork::OnWinsock(WPARAM wParam, LPARAM lParam)
{
	CSingleLock pLock( &m_pSection, TRUE );

	LPBYTE pBuffer = NULL;
	if ( ! m_pLookups.Lookup( (LPVOID)wParam, (LPVOID&)pBuffer ) ) return;
	m_pLookups.RemoveKey( (LPVOID)wParam );

	CString* psHost	= *(CString**)pBuffer;
	WORD nPort		= *(WORD*)(pBuffer + 4);
	BYTE nProtocol	= *(BYTE*)(pBuffer + 6);
	BYTE nCommand	= *(BYTE*)(pBuffer + 7);
	HOSTENT* pHost	= (HOSTENT*)(pBuffer + 8);

	if ( WSAGETASYNCERROR(lParam) == 0 )
	{
		if ( nCommand == 0 )
		{
			HostCache.ForProtocol( nProtocol )->Add( (IN_ADDR*)pHost->h_addr, nPort );
		}
		else
		{
			Neighbours.ConnectTo( (IN_ADDR*)pHost->h_addr, nPort, nProtocol, FALSE, nCommand == 2 );
		}
	}
	else if ( nCommand > 0 )
	{
		theApp.Message( MSG_ERROR, IDS_NETWORK_RESOLVE_FAIL, (LPCTSTR)*psHost );
	}
	
	delete psHost;
	free( pBuffer );
}
void CUploadsWnd::OnContextMenu(CWnd* pWnd, CPoint point)
{
	CSingleLock pLock( &Transfers.m_pSection, TRUE );
	CUploadQueue* pQueue;
	CUploadFile* pUpload;

	CPoint ptLocal( point );
	m_wndUploads.ScreenToClient( &ptLocal );
	m_tSel = 0;

	if ( m_wndUploads.HitTest( ptLocal, &pQueue, &pUpload, NULL, NULL ) )
	{
		if ( pUpload != NULL )
		{
			pLock.Unlock();
			TrackPopupMenu( _T("CUploadsWnd.Upload"), point, ID_UPLOADS_LAUNCH );
			return;
		}
	}

	if( ( pQueue == NULL ) || ( Settings.General.GUIMode == GUI_BASIC ) ||		//If we're not pointing at a queue, or in basic mode
		( pQueue == UploadQueues.m_pHistoryQueue ) || ( pQueue == UploadQueues.m_pTorrentQueue ) )	//Or pointing at a pre-defined queue
		TrackPopupMenu( _T("CUploadsWnd.Nothing"), point, ID_UPLOADS_HELP );
	else
		TrackPopupMenu( _T("CUploadsWnd.Queue"), point, ID_UPLOADS_EDIT_QUEUE );

	pLock.Unlock();
}
Exemple #26
0
void CHostBrowser::Stop(BOOL bCompleted)
{
	CSingleLock pLock( &Transfers.m_pSection, TRUE );

	if ( bCompleted )
	{
		if ( m_pProfile && m_pNotify != NULL )
			m_pNotify->OnProfileReceived();

		theApp.Message( MSG_NOTICE, IDS_BROWSE_FINISHED, (LPCTSTR)m_sAddress, m_nHits );
	}
	else if ( IsValid() )
	{
		theApp.Message( MSG_INFO, IDS_BROWSE_CLOSED, (LPCTSTR)m_sAddress );
	}

	m_nState  = hbsNull;
	m_tPushed = 0;

	// ED2K connections aren't handled here -they are in ED2KClient
	if ( m_nProtocol != PROTOCOL_ED2K && m_nProtocol != PROTOCOL_DC )
		CTransfer::Close();

	CBuffer::InflateStreamCleanup( m_pInflate );
}
void CUploadsWnd::OnUploadsLaunch()
{
	CSingleLock pLock( &Transfers.m_pSection, TRUE );
	CList<CUploadFile*> pList;

	for ( POSITION pos = UploadFiles.GetIterator() ; pos ; )
	{
		CUploadFile* pFile = UploadFiles.GetNext( pos );
		if ( IsSelected( pFile ) ) pList.AddTail( pFile );
	}

	while ( ! pList.IsEmpty() )
	{
		CUploadFile* pFile = pList.RemoveHead();

		if ( UploadFiles.Check( pFile ) )
		{
			CString strPath = pFile->m_sPath;

			pLock.Unlock();
			if ( ! CFileExecutor::Execute( strPath ) ) break;
			pLock.Lock();
		}
	}
}
Exemple #28
0
void CRemote::PageNetwork()
{
	if ( CheckCookie() ) return;
	m_nTab = tabNetwork;

	CSingleLock pLock( &Network.m_pSection );
	if ( ! SafeLock( pLock ) ) return;

	DWORD nNeighbourID = 0;
	_stscanf( GetKey( L"drop" ), L"%lu", &nNeighbourID );

	if ( nNeighbourID != 0 )
	{
		if ( CNeighbour* pNeighbour = Neighbours.Get( nNeighbourID ) )
			pNeighbour->Close( IDS_CONNECTION_CLOSED );
	}

	Prepare();		// Header

	CString str;
	str.Format( L"%i", GetRandomNum( 0i32, _I32_MAX ) );
	Add( L"random", str );
	Output( L"networkHeader" );

	PageNetworkNetwork( PROTOCOL_G2, &Settings.Gnutella2.Enabled, L"Gnutella2" );	// protocolNames[ PROTOCOL_G2 ]
	PageNetworkNetwork( PROTOCOL_G1, &Settings.Gnutella1.Enabled, L"Gnutella" ); 	// protocolNames[ PROTOCOL_G1 ]
	PageNetworkNetwork( PROTOCOL_ED2K, &Settings.eDonkey.Enabled, L"eDonkey" );		// protocolNames[ PROTOCOL_ED2K ]
	PageNetworkNetwork( PROTOCOL_DC, &Settings.DC.Enabled, L"DC++" );				// protocolNames[ PROTOCOL_DC ] )
	PageNetworkNetwork( PROTOCOL_BT, &Settings.BitTorrent.Enabled, L"BitTorrent" );	// protocolNames[ PROTOCOL_BT ] )

	Output( L"networkFooter" );
}
void CLibraryCollectionView::OnWebContextMenu(NMHDR* pNMHDR, LPARAM* pResult)
{
    WVNCONTEXTMENU* pNotify = (WVNCONTEXTMENU*)pNMHDR;

    *pResult = TRUE;

    if ( m_nWebIndex != 0 )
    {
        GetToolTip()->Hide();

        SelClear( FALSE );
        SelAdd( m_nWebIndex );

        CPoint point( pNotify->ptMouse );

        CStringList oFiles;
        {
            CQuickLock pLock( Library.m_pSection );
            POSITION posSel = StartSelectedFileLoop();
            while ( CLibraryFile* pFile = GetNextSelectedFile( posSel ) )
            {
                oFiles.AddTail( pFile->GetPath() );
            }
        }

        CString strName = _T("CLibraryFileView");
        strName += Settings.Library.ShowVirtual ? _T(".Virtual") : _T(".Physical");
        Skin.TrackPopupMenu( strName, point, ID_LIBRARY_LAUNCH, oFiles );
    }
}
Exemple #30
0
void CPrivateChatWnd::OnChatPriority()
{
	if ( ! m_pSession )
		return;

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

	DWORD nAddress = m_pSession->m_pHost.sin_addr.s_addr;

	for ( POSITION pos = Uploads.GetIterator() ; pos ; )
	{
		CUploadTransfer* pUpload = Uploads.GetNext( pos );

		if ( pUpload->m_pHost.sin_addr.s_addr == nAddress &&
			 pUpload->m_nState == upsQueued )
		{
			pUpload->Promote();
		}
	}

	CString strMessage;
	strMessage.Format( LoadString( IDS_CHAT_PRIORITY_GRANTED ), (LPCTSTR)HostToString( &m_pSession->m_pHost ) );
	CChatWnd::OnStatusMessage( 2, strMessage );
}