SessionDescriptorImplPtr XSessionImpl::GetSessionDescription(const XSocketPtr& targetRemoteSystem) const { int32 numUsers = GetUserCount(); SessionDescriptorImplPtr sessionDesc = new SessionDescriptorImpl(); sessionDesc->SetName(GetName()); sessionDesc->SetID(GetId()); sessionDesc->SetSessionType(GetType()); sessionDesc->SetAddress(m_socketMgr->GetLocalAddressForRemoteClient(targetRemoteSystem)); sessionDesc->SetPortID(m_port); sessionDesc->SetUserCount(numUsers); for (int32 userIndex = 0; userIndex < numUsers; ++userIndex) { UserImplPtr tmpUser = new UserImpl( GetSessionUserName(userIndex), GetSessionUserID(userIndex), GetUserMuteState(userIndex)); sessionDesc->SetUser(userIndex, tmpUser); } return sessionDesc; }
BOOL CDCNeighbour::OnQuit(LPSTR szNick) { // User leave hub // $Quit nick| if ( szNick ) { CString sNick = UTF8Decode( szNick ); CChatUser* pUser; if ( m_oUsers.Lookup( sNick, pUser ) ) { m_oUsers.RemoveKey( sNick ); delete pUser; } if ( m_nNodeType == ntHub ) { HostCache.DC.Add( &m_pHost.sin_addr, htons( m_pHost.sin_port ), 0, 0, 0, GetUserCount() ); } // Notify chat window ChatCore.OnDeleteUser( this, new CString( sNick ) ); } return TRUE; }
UserPtr SessionImpl::GetUser(int32 i) { if (i >= 0 && i < GetUserCount()) { return m_users[i]; } else { return NULL; } }
BOOL CDCNeighbour::OnUserInfo(LPSTR szInfo) { // User info // $MyINFO $ALL nick description<tag>$ $connection$e-mail$sharesize$| if ( strncmp( szInfo, _P("$ALL ") ) == 0 ) { LPSTR szNick = szInfo + 5; if ( LPSTR szDescription = strchr( szNick, ' ' ) ) { *szDescription++ = 0; CString sNick( UTF8Decode( szNick ) ); CChatUser* pUser; if ( ! m_oUsers.Lookup( sNick, pUser ) ) { pUser = new CChatUser; m_oUsers.SetAt( sNick, pUser ); } pUser->m_bType = ( sNick == m_sNick ) ? cutMe : cutUser; pUser->m_sNick = sNick; if ( LPSTR szConnection = strchr( szDescription, '$' ) ) { *szConnection++ = 0; if ( LPSTR szVendor = strchr( szDescription, '<' ) ) { if ( *(szConnection - 2) == '>' ) { *szVendor++ = 0; *(szConnection - 2) = 0; CStringA sVersion; if ( LPSTR szTags = strchr( szVendor, ' ' ) ) { *szTags++ = 0; for ( CStringA sTags( szTags ); ! sTags.IsEmpty(); ) { CStringA sTag = sTags.SpanExcluding( "," ); sTags = sTags.Mid( sTag.GetLength() + 1 ); if ( sTag.IsEmpty() ) continue; int nPos = sTag.Find( ':' ); if ( nPos > 0 ) { CStringA sTagName = sTag.Left( nPos ); sTag = sTag.Mid( nPos + 1 ); if ( sTagName == "V" ) { // Version sVersion = sTag; } else if ( sTagName == "M" ) { // Mode } else if ( sTagName == "H" ) { // Hubs } else if ( sTagName == "S" ) { // Slots } } } } pUser->m_sUserAgent = UTF8Decode( szVendor ); if ( ! sVersion.IsEmpty() ) pUser->m_sUserAgent += _T(" ") + UTF8Decode( sVersion ); } } } pUser->m_sDescription = UTF8Decode( szDescription ); if ( m_nNodeType == ntHub ) { HostCache.DC.Add( &m_pHost.sin_addr, htons( m_pHost.sin_port ), 0, 0, 0, GetUserCount() ); } // Notify chat window ChatCore.OnAddUser( this, new CChatUser( *pUser ) ); } } return TRUE; }