void CRemoteWnd::OnNcLButtonDblClk(UINT /*nFlags*/, CPoint point) { if ( m_bsHistoryDest && m_rcsHistoryDest.PtInRect( point ) ) { PostMainWndMessage( WM_COMMAND, ID_TAB_HOME ); } else if ( m_bsStatusText && m_rcsStatusText.PtInRect( point ) ) { PostMainWndMessage( WM_COMMAND, ID_TAB_MEDIA ); } else { PostMainWndMessage( WM_COMMAND, ID_TRAY_OPEN ); } }
CPrivateChatWnd* CChatWindows::OpenPrivate(const Hashes::Guid& oGUID, const SOCKADDR_IN* pHost, BOOL bMustPush, PROTOCOLID nProtocol, SOCKADDR_IN* pServer) { if ( ! MyProfile.IsValid() ) { CString strMessage; LoadString( strMessage, IDS_CHAT_NEED_PROFILE ); if ( MsgBox( strMessage, MB_YESNO|MB_ICONQUESTION ) == IDYES ) PostMainWndMessage( WM_COMMAND, ID_TOOLS_PROFILE ); return NULL; } switch ( nProtocol ) { case PROTOCOL_G1: Settings.Gnutella1.Enabled = true; return OpenPrivateGnutella( oGUID, pHost, bMustPush, PROTOCOL_ANY ); case PROTOCOL_G2: case PROTOCOL_HTTP: Settings.Gnutella2.Enabled = true; return OpenPrivateGnutella( oGUID, pHost, bMustPush, PROTOCOL_ANY ); case PROTOCOL_ED2K: Settings.eDonkey.Enabled = true; return OpenPrivateED2K( oGUID, pHost, bMustPush, pServer ); default: return NULL; } }
void CLibrarySettingsPage::OnRecentClearGhosts() { CQuickLock oLock( Library.m_pSection ); LibraryFolders.ClearGhosts(); Library.Update(); PostMainWndMessage( WM_COMMAND, ID_LIBRARY_REFRESH ); //m_wndRecentClearGhosts.EnableWindow( FALSE ); GetDlgItem( IDC_RECENT_CLEAR_GHOSTS )->EnableWindow( FALSE ); }
BOOL CHomeDownloadsBox::ExecuteDownload(CDownload* pDownload) { CSingleLock pLock( &Transfers.m_pSection ); if ( ! pLock.Lock( 1000 ) ) return FALSE; if ( ! Downloads.Check( pDownload ) ) return FALSE; if ( ! pDownload->Launch( -1, &pLock, FALSE ) ) PostMainWndMessage( WM_COMMAND, ID_VIEW_DOWNLOADS ); return TRUE; }
BOOL CCollectionFile::File::Download() { CEnvyURL pURL; pURL.m_nAction = CEnvyURL::uriDownload; pURL.m_oSHA1 = m_oSHA1; pURL.m_oMD5 = m_oMD5; pURL.m_oTiger = m_oTiger; pURL.m_oED2K = m_oED2K; pURL.m_oBTH = m_oBTH; pURL.m_sName = m_sName; pURL.m_nSize = m_nSize; return PostMainWndMessage( WM_URL, (WPARAM)new CEnvyURL( pURL ) ); }
BOOL CSecurity::Import(LPCTSTR pszFile) { CString strText; CBuffer pBuffer; CFile pFile; if ( ! pFile.Open( pszFile, CFile::modeRead ) ) return FALSE; pBuffer.EnsureBuffer( (DWORD)pFile.GetLength() ); pBuffer.m_nLength = (DWORD)pFile.GetLength(); pFile.Read( pBuffer.m_pBuffer, pBuffer.m_nLength ); pFile.Close(); CXMLElement* pXML = CXMLElement::FromBytes( pBuffer.m_pBuffer, pBuffer.m_nLength, TRUE ); BOOL bResult = FALSE; if ( pXML != NULL ) { bResult = FromXML( pXML ); delete pXML; } else { CString strLine; while ( pBuffer.ReadLine( strLine ) ) { strLine.Trim(); if ( strLine.IsEmpty() ) continue; if ( strLine.GetAt( 0 ) == ';' ) continue; CSecureRule* pRule = new CSecureRule(); if ( pRule->FromGnucleusString( strLine ) ) { CQuickLock oLock( m_pSection ); m_pRules.AddTail( pRule ); bResult = TRUE; } else { delete pRule; } } } // Check all lists for newly denied hosts PostMainWndMessage( WM_SANITY_CHECK ); return bResult; }
void CNetworksSettingsPage::Update() { if ( (BOOL)Settings.Gnutella1.ShowInterface == m_bG1Enable && (BOOL)Settings.eDonkey.ShowInterface == m_bEDEnable && (BOOL)Settings.DC.ShowInterface == m_bDCEnable ) return; //Settings.Gnutella2.ShowInterface = m_bG2Enable != FALSE; Settings.Gnutella1.ShowInterface = m_bG1Enable != FALSE; Settings.eDonkey.ShowInterface = m_bEDEnable != FALSE; Settings.DC.ShowInterface = m_bDCEnable != FALSE; // Update Interface PostMainWndMessage( WM_SKINCHANGED ); }
void CSecurity::Add(CSecureRule* pRule) { { CQuickLock oLock( m_pSection ); if ( pRule->m_nAction == CSecureRule::srDeny ) { if ( pRule->m_nType == CSecureRule::srAddress ) { pRule->MaskFix(); if ( *(DWORD*)pRule->m_nMask == 0xffffffff ) m_Cache.erase( *(DWORD*)pRule->m_nIP ); else m_Cache.clear(); if ( *(DWORD*)pRule->m_nMask == 0xffffffff && pRule->m_nExpire == CSecureRule::srIndefinite ) SetAddressMap( *(DWORD*)pRule->m_nIP, SetRuleIndex( pRule ) ); } else if ( pRule->m_nType == CSecureRule::srContentHash ) { if ( pRule->m_nExpire == CSecureRule::srIndefinite ) SetHashMap( pRule->GetContentWords(), SetRuleIndex( pRule ) ); } else if ( pRule->m_nType == CSecureRule::srExternal ) { ListLoader.AddList( pRule ); } } CSecureRule* pExistingRule = GetGUID( pRule->m_pGUID ); if ( pExistingRule == NULL ) { m_pRules.AddHead( pRule ); } else if ( pExistingRule != pRule ) { *pExistingRule = *pRule; delete pRule; } } // Check all lists for newly denied hosts PostMainWndMessage( WM_SANITY_CHECK ); }
BOOL CUploadTransferDC::SendFile() { if ( ! OpenFile() ) { theApp.Message( MSG_ERROR, IDS_UPLOAD_CANTOPEN, (LPCTSTR)m_sName, (LPCTSTR)m_sAddress ); m_pClient->SendCommand( FILE_NOT_AVAILABLE ); return FALSE; } if ( m_bGet ) { m_bGet = FALSE; } else { CString strAnswer; strAnswer.Format( _T("$ADCSND file TTH/%s %I64u %I64u|"), m_oTiger.toString(), m_nOffset, m_nLength ); m_pClient->SendCommand( strAnswer ); } StartSending( upsUploading ); if ( m_pBaseFile->m_nRequests++ == 0 ) { theApp.Message( MSG_NOTICE, IDS_UPLOAD_FILE, (LPCTSTR)m_sName, (LPCTSTR)m_sAddress ); //ASSERT( m_pBaseFile->m_sPath.GetLength() ); PostMainWndMessage( WM_NOWUPLOADING, 0, (LPARAM)new CString( m_pBaseFile->m_sPath ) ); } theApp.Message( MSG_INFO, IDS_UPLOAD_CONTENT, m_nOffset, m_nOffset + m_nLength - 1, (LPCTSTR)m_sName, (LPCTSTR)m_sAddress, (LPCTSTR)m_sUserAgent ); return TRUE; }
LRESULT CWizardInterfacePage::OnWizardNext() { UpdateData( TRUE ); Settings.Downloads.SimpleBar = m_bSimpleDownloadBars != FALSE; if ( ! m_bBasic && Settings.General.GUIMode == GUI_BASIC ) { CWaitCursor pCursor; CMainWnd* pMainWnd = (CMainWnd*)AfxGetMainWnd(); Settings.Skin.RowSize = 17; Settings.General.GUIMode = GUI_TABBED; pMainWnd->SetGUIMode( Settings.General.GUIMode, FALSE ); } else if ( m_bBasic && Settings.General.GUIMode != GUI_BASIC ) { CWaitCursor pCursor; CMainWnd* pMainWnd = (CMainWnd*)AfxGetMainWnd(); Settings.Skin.RowSize = 18; Settings.General.GUIMode = GUI_BASIC; pMainWnd->SetGUIMode( Settings.General.GUIMode, FALSE ); } Settings.Save(); if ( m_nSkin ) { CWaitCursor pCursor; ClearSkins(); if ( m_nSkin == 2 && theApp.m_nWinVer >= WIN_10) // Dark Mode { theApp.WriteProfileInt( L"Skins", L"Windows 10\\Windows10.Dark.xml", 1 ); theApp.WriteProfileInt( L"Skins", L"Windows 10\\Windows10.DarkFrames.xml", 1 ); } else if ( m_nSkin == 2) // Dark Skin { theApp.WriteProfileInt( L"Skins", L"Windows Collection\\SkinDark.xml", 1 ); theApp.WriteProfileInt( L"Skins", L"Windows Collection\\Skin8AltFrames.xml", 1 ); theApp.WriteProfileInt( L"Skins", L"Windows Collection\\SkinVistaRemote.xml", 1 ); } else if ( theApp.m_nWinVer >= WIN_10 ) { theApp.WriteProfileInt( L"Skins", L"Windows 10\\Windows10.xml", 1 ); theApp.WriteProfileInt( L"Skins", L"Windows 10\\Windows10.Frames.xml", 1 ); } else if ( theApp.m_nWinVer >= WIN_8 ) { theApp.WriteProfileInt( L"Skins", L"Windows Collection\\Skin8.xml", 1 ); theApp.WriteProfileInt( L"Skins", L"Windows Collection\\Skin8Frames.xml", 1 ); } else if ( theApp.m_nWinVer >= WIN_7 ) { theApp.WriteProfileInt( L"Skins", L"Windows Collection\\Skin7.xml", 1 ); theApp.WriteProfileInt( L"Skins", L"Windows Collection\\SkinVistaFrames.xml", 1 ); theApp.WriteProfileInt( L"Skins", L"Windows Collection\\SkinVistaRemote.xml", 1 ); } else if ( theApp.m_nWinVer < WIN_7 ) { theApp.WriteProfileInt( L"Skins", L"Windows Collection\\SkinVista.xml", 1 ); theApp.WriteProfileInt( L"Skins", L"Windows Collection\\SkinVistaFrames.xml", 1 ); theApp.WriteProfileInt( L"Skins", L"Windows Collection\\SkinVistaRemote.xml", 1 ); } if ( theApp.m_nWinVer >= WIN_7 && GetSystemMetrics( SM_CYSCREEN ) > 1050 ) // ToDo: Detect DPI theApp.WriteProfileInt( L"Skins", L"Flags\\Flags.xml", 1 ); PostMainWndMessage( WM_SKINCHANGED ); Sleep( 2500 ); // Wait a few seconds GetParent()->Invalidate(); } return 0; }
void CScheduler::Execute(const CString& sTaskData) { int nAction, nLimitDown, nLimitUp, nDisabled, nEnabled; if ( _stscanf( sTaskData, _T("%d:%d:%d:%d:%d"), &nAction, &nLimitDown, &nLimitUp, &nDisabled, &nEnabled ) != 5 || nAction < BANDWIDTH_FULLSPEED || nAction > SYSTEM_START || nLimitDown < 0 || nLimitDown > 100 || nLimitUp < 0 || nLimitUp > 100 || nDisabled < 0 || nEnabled < 0 ) // Invalid argument return; if ( nAction == BANDWIDTH_FULLSPEED || nAction == BANDWIDTH_REDUCEDSPEED ) { if ( nEnabled & 1 ) Settings.Gnutella1.EnableToday = true; else if ( nDisabled & 1 ) Settings.Gnutella1.EnableToday = false; if ( nEnabled & 2 ) Settings.Gnutella2.EnableToday = true; else if ( nDisabled & 2 ) Settings.Gnutella2.EnableToday = false; if ( nEnabled & 4 ) Settings.eDonkey.EnableToday = true; else if ( nDisabled & 4 ) Settings.eDonkey.EnableToday = false; if ( nEnabled & 8 ) Settings.DC.EnableToday = true; else if ( nDisabled & 8 ) Settings.DC.EnableToday = false; if ( nEnabled & 16 ) Settings.BitTorrent.EnableToday = true; else if ( nDisabled & 16 ) Settings.BitTorrent.EnableToday = false; } switch ( nAction ) { case BANDWIDTH_FULLSPEED: Settings.Live.BandwidthScale = 100; // No Limit Settings.Bandwidth.Downloads = 0; // Reset upload limit to 90% of capacity, trimmed down to the nearest KB. Settings.Bandwidth.Uploads = ( ( ( Settings.Connection.OutSpeed * ( 100 - Settings.Uploads.FreeBandwidthFactor ) ) / 100 ) / Bytes ) * Kilobits; if ( ! Network.IsConnected() ) Network.Connect( TRUE ); break; case BANDWIDTH_REDUCEDSPEED: if ( nLimitDown == nLimitUp ) { Settings.Live.BandwidthScale = nLimitDown; // No Limit Settings.Bandwidth.Downloads = 0; // Reset upload limit to 90% of capacity, trimmed down to the nearest KB. Settings.Bandwidth.Uploads = ( ( ( Settings.Connection.OutSpeed * ( 100 - Settings.Uploads.FreeBandwidthFactor ) ) / 100 ) / Bytes ) * Kilobits; } else { Settings.Live.BandwidthScale = 100; Settings.Bandwidth.Downloads = ( ( Settings.Connection.InSpeed * Kilobits / Bytes ) * nLimitDown ) / 100; Settings.Bandwidth.Uploads = ( ( Settings.Connection.OutSpeed * Kilobits / Bytes ) * nLimitUp ) / 100; } if ( ! Network.IsConnected() ) Network.Connect( TRUE ); break; case BANDWIDTH_STOP: Settings.Live.BandwidthScale = 0; Settings.Gnutella1.EnableToday = false; Settings.Gnutella2.EnableToday = false; Settings.eDonkey.EnableToday = false; Settings.DC.EnableToday = false; Settings.BitTorrent.EnableToday = false; if ( Network.IsConnected() ) Network.Disconnect(); break; case SYSTEM_DIALUP_DC: Settings.Live.BandwidthScale = 0; Settings.Gnutella1.EnableToday = false; Settings.Gnutella2.EnableToday = false; Settings.eDonkey.EnableToday = false; Settings.DC.EnableToday = false; Settings.BitTorrent.EnableToday = false; if ( Network.IsConnected() ) Network.Disconnect(); HangUpConnection(); break; case SYSTEM_EXIT: // Close self PostMainWndMessage( WM_CLOSE ); break; case SYSTEM_SHUTDOWN: // Begin shutdown if ( SetShutdownRights()&& ShutDownComputer() ) { // Close Shareaza if shutdown successfully started PostMainWndMessage( WM_CLOSE ); } break; case SYSTEM_START: // Unexpected break; } }
void CListLoader::OnRun() { while ( IsThreadEnabled() && m_pQueue.GetCount() ) { CSecureRule* pRule = m_pQueue.GetHead(); if ( ! pRule || ! pRule->m_pContent || pRule->m_nType != CSecureRule::srExternal ) { m_pQueue.RemoveHead(); continue; } CString strPath = pRule->GetContentWords(); if ( strPath.GetLength() < 6 ) { m_pQueue.RemoveHead(); continue; } CString strCommentBase = pRule->m_sComment; if ( strCommentBase.IsEmpty() ) strCommentBase = _T("• %u"); else if ( strCommentBase.ReverseFind( _T('•') ) >= 0 ) strCommentBase = strCommentBase.Left( strCommentBase.ReverseFind( _T('•') ) + 1 ) + _T(" %u"); else strCommentBase += _T(" • %u"); if ( strPath[1] != _T(':') ) strPath = Settings.General.DataPath + strPath; CFile pFile; if ( ! pFile.Open( (LPCTSTR)strPath.GetBuffer(), CFile::modeRead ) ) { m_pQueue.RemoveHead(); continue; } const BYTE nIndex = Security.SetRuleIndex( pRule ); try { CBuffer pBuffer; const DWORD nLength = pFile.GetLength(); pBuffer.EnsureBuffer( nLength ); pBuffer.m_nLength = nLength; pFile.Read( pBuffer.m_pBuffer, nLength ); pFile.Close(); // Format: Delineated Lists CString strLine, strURN; DWORD nCount = 0; int nPos; //TIMER_START while ( pBuffer.ReadLine( strLine ) && IsThreadEnabled() && pRule ) { strLine.TrimRight(); if ( strLine.GetLength() < 7 ) continue; // Blank/Invalid line if ( strLine[ 0 ] == '#' ) { if ( strLine[ strLine.GetLength() - 1 ] == _T(':') && strLine.Find( _T("urn:") ) > 0 ) strURN = strLine.Mid( strLine.Find( _T("urn:") ) ); // Default "# urn:type:" continue; // Comment line } if ( strLine[ 0 ] < '0' || strLine[ 0 ] > 'z' ) // Whitespace/Chars continue; // Invalid line if ( ++nCount % 10 == 0 ) { if ( pRule->m_sComment.IsEmpty() ) strCommentBase = _T("• %u"); else if ( pRule->m_sComment.ReverseFind( _T('•') ) < 0 ) strCommentBase = pRule->m_sComment + _T(" • %u"); pRule->m_sComment.Format( strCommentBase, nCount ); Sleep( 1 ); // Limit CPU } // Hashes: if ( ( ! strURN.IsEmpty() && strLine.Find( _T('.'), 5 ) < 0 ) || StartsWith( strLine, _PT("urn:") ) ) { nPos = strLine.FindOneOf( _T(" \t") ); if ( nPos > 0 ) strLine.Truncate( nPos ); // Trim at whitespace (remove any trailing comments) if ( ! strURN.IsEmpty() && ! StartsWith( strLine, _PT("urn:") ) ) strLine = strURN + strLine; // Default "urn:type:" prepended if ( strLine.GetLength() > 35 ) Security.SetHashMap( strLine, nIndex ); else nCount--; continue; } // IPs: nPos = strLine.ReverseFind( _T(':') ); if ( nPos > 0 ) strLine = strLine.Mid( nPos + 1 ); // Remove leading comment for some formats nPos = strLine.FindOneOf( _T(" \t") ); if ( nPos > 0 ) strLine.Truncate( nPos ); // Trim at whitespace (remove any trailing comments) if ( strLine.GetLength() < 7 || strLine.Find( _T('.') ) < 1 ) { nCount--; continue; } nPos = strLine.Find( _T('-') ); // Possible Range if ( nPos < 0 ) // Single IP { Security.SetAddressMap( IPStringToDWORD( strLine, TRUE ), nIndex ); continue; } CString strFirst = strLine.Left( nPos ); CString strLast = strLine.Mid( nPos + 1 ); if ( strFirst == strLast ) { Security.SetAddressMap( IPStringToDWORD( strLine, TRUE ), nIndex ); continue; } // inet_addr( CT2CA( (LPCTSTR)strLast ) DWORD nFirst = IPStringToDWORD( strFirst, FALSE ); DWORD nLast = IPStringToDWORD( strLast, FALSE ); if ( nFirst < 10 || nFirst >= 0xE0000000 ) // 0 or "0.0." or "224-255" continue; // Redundant/Invalid //if ( Network.IsReserved( (IN_ADDR*)nFirst ) ) // Crash //if ( StartsWith( strFirst, _PT("0.0") ) || // StartsWith( strFirst, _PT("6.0") ) || // StartsWith( strFirst, _PT("7.0") ) || // StartsWith( strFirst, _PT("11.0") ) || // StartsWith( strFirst, _PT("55.0") ) || // StartsWith( strFirst, _PT("127.0") ) ) // continue; // Redundant for ( DWORD nRange = Settings.Security.ListRangeLimit ; nFirst <= nLast && nRange ; nFirst++, nRange-- ) { Security.SetAddressMap( htonl( nFirst ), nIndex ); // Reverse host-byte order } } if ( pRule ) pRule->m_sComment.Format( strCommentBase, nCount ); // Final update PostMainWndMessage( WM_SANITY_CHECK ); //TIMER_STOP } catch ( CException* pException ) { if ( pFile.m_hFile != CFile::hFileNull ) pFile.Close(); // File is still open so close it pException->Delete(); } m_pQueue.RemoveHead(); // Done } Exit(); Wakeup(); Sleep( 5000 ); // Recheck if ( ! m_pQueue.GetCount() ) // && IsThreadEnabled() { CQuickLock oLock( Security.m_pSection ); Security.m_Cache.clear(); PostMainWndMessage( WM_SANITY_CHECK ); } }