diff --git a/src/channel.cpp b/src/channel.cpp index b9a112d1..0a8fb4b2 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -46,8 +46,8 @@ CChannel::CChannel ( const bool bNIsServer ) : // init the socket buffer SetSockBufNumFrames ( DEF_NET_BUF_SIZE_NUM_BL ); - // initialize channel name - ResetName(); + // initialize channel info + ResetInfo(); // Connections ------------------------------------------------------------- @@ -64,16 +64,20 @@ CChannel::CChannel ( const bool bNIsServer ) : SIGNAL ( ReqJittBufSize() ) ); QObject::connect ( &Protocol, - SIGNAL ( ReqChanName() ), - SIGNAL ( ReqChanName() ) ); + SIGNAL ( ReqChanInfo() ), + SIGNAL ( ReqChanInfo() ) ); QObject::connect ( &Protocol, SIGNAL ( ReqConnClientsList() ), SIGNAL ( ReqConnClientsList() ) ); QObject::connect ( &Protocol, - SIGNAL ( ConClientListMesReceived ( CVector ) ), - SIGNAL ( ConClientListMesReceived ( CVector ) ) ); + SIGNAL ( ConClientListNameMesReceived ( CVector ) ), + SIGNAL ( ConClientListNameMesReceived ( CVector ) ) ); + + QObject::connect ( &Protocol, + SIGNAL ( ConClientListMesReceived ( CVector ) ), + SIGNAL ( ConClientListMesReceived ( CVector ) ) ); QObject::connect( &Protocol, SIGNAL ( ChangeChanGain ( int, double ) ), this, SLOT ( OnChangeChanGain ( int, double ) ) ); @@ -81,6 +85,9 @@ CChannel::CChannel ( const bool bNIsServer ) : QObject::connect( &Protocol, SIGNAL ( ChangeChanName ( QString ) ), this, SLOT ( OnChangeChanName ( QString ) ) ); + QObject::connect( &Protocol, SIGNAL ( ChangeChanInfo ( CChannelCoreInfo ) ), + this, SLOT ( OnChangeChanInfo ( CChannelCoreInfo ) ) ); + QObject::connect( &Protocol, SIGNAL ( ChatTextReceived ( QString ) ), SIGNAL ( ChatTextReceived ( QString ) ) ); @@ -220,17 +227,29 @@ double CChannel::GetGain ( const int iChanID ) } } +void CChannel::SetChanInfo ( const CChannelCoreInfo& NChanInf ) +{ + // apply value (if different from previous one) + if ( ChannelInfo != NChanInf ) + { + ChannelInfo = NChanInf; + + // fire message that the channel info has changed + emit ChanInfoHasChanged(); + } +} + void CChannel::SetName ( const QString strNewName ) { bool bNameHasChanged = false; Mutex.lock(); { - // apply value (if different from previous name) - if ( sName.compare ( strNewName ) ) + // apply value (if different from previous one) + if ( ChannelInfo.strName.compare ( strNewName ) ) { - sName = strNewName; - bNameHasChanged = true; + ChannelInfo.strName = strNewName; + bNameHasChanged = true; } } Mutex.unlock(); @@ -239,7 +258,7 @@ void CChannel::SetName ( const QString strNewName ) if ( bNameHasChanged ) { // the "emit" has to be done outside the mutexed region - emit NameHasChanged(); + emit ChanInfoHasChanged(); } } QString CChannel::GetName() @@ -248,7 +267,7 @@ QString CChannel::GetName() // read here -> use mutex to secure access QMutexLocker locker ( &Mutex ); - return sName; + return ChannelInfo.strName; } void CChannel::OnSendProtMessage ( CVector vecMessage ) @@ -301,6 +320,11 @@ void CChannel::OnChangeChanName ( QString strName ) SetName ( strName ); } +void CChannel::OnChangeChanInfo ( CChannelCoreInfo ChanInfo ) +{ + SetChanInfo ( ChanInfo ); +} + bool CChannel::GetAddress ( CHostAddress& RetAddr ) { QMutexLocker locker ( &Mutex ); diff --git a/src/channel.h b/src/channel.h index 266dca79..67c1def7 100755 --- a/src/channel.h +++ b/src/channel.h @@ -79,12 +79,21 @@ public: bool GetAddress ( CHostAddress& RetAddr ); CHostAddress GetAddress() const { return InetAddr; } - void ResetName() { sName = ""; } // reset does not emit a message + void ResetInfo() { ChannelInfo = CChannelCoreInfo(); } // reset does not emit a message void SetName ( const QString sNNa ); QString GetName(); + void SetChanInfo ( const CChannelCoreInfo& NChanInf ); + CChannelCoreInfo& GetChanInfo() { return ChannelInfo; } - void SetRemoteName ( const QString strName ) { Protocol.CreateChanNameMes ( strName ); } - void CreateReqChanNameMes() { Protocol.CreateReqChanNameMes(); } + void SetRemoteInfo ( const CChannelCoreInfo ChInfo ) + { + // because of compatibility to old versions, we also have to send the + // channel name message extra +// #### COMPATIBILITY OLD VERSION, TO BE REMOVED #### +Protocol.CreateChanNameMes ( ChInfo.strName ); + Protocol.CreateChanInfoMes ( ChInfo ); + } + void CreateReqChanInfoMes() { Protocol.CreateReqChanInfoMes(); } void SetGain ( const int iChanID, const double dNewGain ); double GetGain ( const int iChanID ); @@ -128,10 +137,12 @@ public: void CreateChatTextMes ( const QString& strChatText ) { Protocol.CreateChatTextMes ( strChatText ); } void CreatePingMes ( const int iMs ) { Protocol.CreatePingMes ( iMs ); } - void CreateConClientListMes ( const CVector& vecChanInfo ) - { - Protocol.CreateConClientListMes ( vecChanInfo ); - } +// #### COMPATIBILITY OLD VERSION, TO BE REMOVED #### +void CreateConClientListNameMes ( const CVector& vecChanInfo ) + { Protocol.CreateConClientListNameMes ( vecChanInfo ); } + + void CreateConClientListMes ( const CVector& vecChanInfo ) + { Protocol.CreateConClientListMes ( vecChanInfo ); } void CreateNetTranspPropsMessFromCurrentSettings(); @@ -139,43 +150,44 @@ protected: bool ProtocolIsEnabled(); // connection parameters - CHostAddress InetAddr; + CHostAddress InetAddr; - // channel name - QString sName; + // channel info + CChannelCoreInfo ChannelInfo; // mixer and effect settings - CVector vecdGains; + CVector vecdGains; // network jitter-buffer - CNetBufWithStats SockBuf; - int iCurSockBufNumFrames; - bool bDoAutoSockBufSize; + CNetBufWithStats SockBuf; + int iCurSockBufNumFrames; + bool bDoAutoSockBufSize; // network output conversion buffer - CConvBuf ConvBuf; + CConvBuf ConvBuf; // network protocol - CProtocol Protocol; + CProtocol Protocol; - int iConTimeOut; - int iConTimeOutStartVal; + int iConTimeOut; + int iConTimeOutStartVal; - bool bIsEnabled; - bool bIsServer; + bool bIsEnabled; + bool bIsServer; - int iNetwFrameSizeFact; - int iNetwFrameSize; + int iNetwFrameSizeFact; + int iNetwFrameSize; - int iNumAudioChannels; + int iNumAudioChannels; - QMutex Mutex; + QMutex Mutex; public slots: void OnSendProtMessage ( CVector vecMessage ); void OnJittBufSizeChange ( int iNewJitBufSize ); void OnChangeChanGain ( int iChanID, double dNewGain ); void OnChangeChanName ( QString strName ); + void OnChangeChanInfo ( CChannelCoreInfo ChanInfo ); void OnNetTranspPropsReceived ( CNetworkTransportProps NetworkTransportProps ); void OnReqNetTranspProps(); @@ -186,9 +198,10 @@ signals: void JittBufSizeChanged ( int iNewJitBufSize ); void ServerAutoSockBufSizeChange ( int iNNumFra ); void ReqConnClientsList(); - void ConClientListMesReceived ( CVector vecChanInfo ); - void NameHasChanged(); - void ReqChanName(); + void ConClientListNameMesReceived ( CVector vecChanInfo ); + void ConClientListMesReceived ( CVector vecChanInfo ); + void ChanInfoHasChanged(); + void ReqChanInfo(); void ChatTextReceived ( QString strChatText ); void PingReceived ( int iMs ); void ReqNetTranspProps(); diff --git a/src/client.cpp b/src/client.cpp index 1a8514db..8b43682a 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -28,7 +28,7 @@ /* Implementation *************************************************************/ CClient::CClient ( const quint16 iPortNumber ) : vstrIPAddress ( MAX_NUM_SERVER_ADDR_ITEMS, "" ), - strName ( "" ), + ChannelInfo (), Channel ( false ), /* we need a client channel -> "false" */ iCeltNumCodedBytes ( CELT_NUM_BYTES_MONO_NORMAL_QUALITY ), bCeltDoHighQuality ( false ), @@ -94,12 +94,16 @@ CClient::CClient ( const quint16 iPortNumber ) : QObject::connect ( &Channel, SIGNAL ( JittBufSizeChanged ( int ) ), this, SLOT ( OnJittBufSizeChanged ( int ) ) ); - QObject::connect ( &Channel, SIGNAL ( ReqChanName() ), - this, SLOT ( OnReqChanName() ) ); + QObject::connect ( &Channel, SIGNAL ( ReqChanInfo() ), + this, SLOT ( OnReqChanInfo() ) ); QObject::connect ( &Channel, - SIGNAL ( ConClientListMesReceived ( CVector ) ), - SIGNAL ( ConClientListMesReceived ( CVector ) ) ); + SIGNAL ( ConClientListNameMesReceived ( CVector ) ), + SIGNAL ( ConClientListNameMesReceived ( CVector ) ) ); + + QObject::connect ( &Channel, + SIGNAL ( ConClientListMesReceived ( CVector ) ), + SIGNAL ( ConClientListMesReceived ( CVector ) ) ); QObject::connect ( &Channel, SIGNAL ( Disconnected() ), @@ -172,9 +176,9 @@ void CClient::OnJittBufSizeChanged ( int iNewJitBufSize ) void CClient::OnNewConnection() { - // a new connection was successfully initiated, send name and request + // a new connection was successfully initiated, send infos and request // connected clients list - Channel.SetRemoteName ( strName ); + Channel.SetRemoteInfo ( ChannelInfo ); // We have to send a connected clients list request since it can happen // that we just had connected to the server and then disconnected but diff --git a/src/server.cpp b/src/server.cpp index a01ba727..d879e9c3 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -369,19 +369,19 @@ CServer::CServer ( const int iNewNumChan, QObject::connect ( &vecChannels[10], SIGNAL ( ReqConnClientsList() ), this, SLOT ( OnReqConnClientsListCh10() ) ); QObject::connect ( &vecChannels[11], SIGNAL ( ReqConnClientsList() ), this, SLOT ( OnReqConnClientsListCh11() ) ); - // channel name has changed - QObject::connect ( &vecChannels[0], SIGNAL ( NameHasChanged() ), this, SLOT ( OnNameHasChangedCh0() ) ); - QObject::connect ( &vecChannels[1], SIGNAL ( NameHasChanged() ), this, SLOT ( OnNameHasChangedCh1() ) ); - QObject::connect ( &vecChannels[2], SIGNAL ( NameHasChanged() ), this, SLOT ( OnNameHasChangedCh2() ) ); - QObject::connect ( &vecChannels[3], SIGNAL ( NameHasChanged() ), this, SLOT ( OnNameHasChangedCh3() ) ); - QObject::connect ( &vecChannels[4], SIGNAL ( NameHasChanged() ), this, SLOT ( OnNameHasChangedCh4() ) ); - QObject::connect ( &vecChannels[5], SIGNAL ( NameHasChanged() ), this, SLOT ( OnNameHasChangedCh5() ) ); - QObject::connect ( &vecChannels[6], SIGNAL ( NameHasChanged() ), this, SLOT ( OnNameHasChangedCh6() ) ); - QObject::connect ( &vecChannels[7], SIGNAL ( NameHasChanged() ), this, SLOT ( OnNameHasChangedCh7() ) ); - QObject::connect ( &vecChannels[8], SIGNAL ( NameHasChanged() ), this, SLOT ( OnNameHasChangedCh8() ) ); - QObject::connect ( &vecChannels[9], SIGNAL ( NameHasChanged() ), this, SLOT ( OnNameHasChangedCh9() ) ); - QObject::connect ( &vecChannels[10], SIGNAL ( NameHasChanged() ), this, SLOT ( OnNameHasChangedCh10() ) ); - QObject::connect ( &vecChannels[11], SIGNAL ( NameHasChanged() ), this, SLOT ( OnNameHasChangedCh11() ) ); + // channel info has changed + QObject::connect ( &vecChannels[0], SIGNAL ( ChanInfoHasChanged() ), this, SLOT ( OnChanInfoHasChangedCh0() ) ); + QObject::connect ( &vecChannels[1], SIGNAL ( ChanInfoHasChanged() ), this, SLOT ( OnChanInfoHasChangedCh1() ) ); + QObject::connect ( &vecChannels[2], SIGNAL ( ChanInfoHasChanged() ), this, SLOT ( OnChanInfoHasChangedCh2() ) ); + QObject::connect ( &vecChannels[3], SIGNAL ( ChanInfoHasChanged() ), this, SLOT ( OnChanInfoHasChangedCh3() ) ); + QObject::connect ( &vecChannels[4], SIGNAL ( ChanInfoHasChanged() ), this, SLOT ( OnChanInfoHasChangedCh4() ) ); + QObject::connect ( &vecChannels[5], SIGNAL ( ChanInfoHasChanged() ), this, SLOT ( OnChanInfoHasChangedCh5() ) ); + QObject::connect ( &vecChannels[6], SIGNAL ( ChanInfoHasChanged() ), this, SLOT ( OnChanInfoHasChangedCh6() ) ); + QObject::connect ( &vecChannels[7], SIGNAL ( ChanInfoHasChanged() ), this, SLOT ( OnChanInfoHasChangedCh7() ) ); + QObject::connect ( &vecChannels[8], SIGNAL ( ChanInfoHasChanged() ), this, SLOT ( OnChanInfoHasChangedCh8() ) ); + QObject::connect ( &vecChannels[9], SIGNAL ( ChanInfoHasChanged() ), this, SLOT ( OnChanInfoHasChangedCh9() ) ); + QObject::connect ( &vecChannels[10], SIGNAL ( ChanInfoHasChanged() ), this, SLOT ( OnChanInfoHasChangedCh10() ) ); + QObject::connect ( &vecChannels[11], SIGNAL ( ChanInfoHasChanged() ), this, SLOT ( OnChanInfoHasChangedCh11() ) ); // chat text received QObject::connect ( &vecChannels[0], SIGNAL ( ChatTextReceived ( QString ) ), this, SLOT ( OnChatTextReceivedCh0 ( QString ) ) ); @@ -837,9 +837,9 @@ CVector CServer::ProcessData ( const int iCurIndex, return vecsOutData; } -CVector CServer::CreateChannelList() +CVector CServer::CreateChannelList() { - CVector vecChanInfo ( 0 ); + CVector vecChanInfo ( 0 ); // look for free channels for ( int i = 0; i < iNumChannels; i++ ) @@ -847,10 +847,10 @@ CVector CServer::CreateChannelList() if ( vecChannels[i].IsConnected() ) { // append channel ID, IP address and channel name to storing vectors - vecChanInfo.Add ( CChannelShortInfo ( + vecChanInfo.Add ( CChannelInfo ( i, // ID vecChannels[i].GetAddress().InetAddr.toIPv4Address(), // IP address - vecChannels[i].GetName() /* name */ ) ); + vecChannels[i].GetChanInfo() ) ); } } @@ -860,7 +860,7 @@ CVector CServer::CreateChannelList() void CServer::CreateAndSendChanListForAllConChannels() { // create channel list - CVector vecChanInfo ( CreateChannelList() ); + CVector vecChanInfo ( CreateChannelList() ); // now send connected channels list to all connected clients for ( int i = 0; i < iNumChannels; i++ ) @@ -868,6 +868,8 @@ void CServer::CreateAndSendChanListForAllConChannels() if ( vecChannels[i].IsConnected() ) { // send message +// #### COMPATIBILITY OLD VERSION, TO BE REMOVED #### +vecChannels[i].CreateConClientListNameMes ( vecChanInfo ); vecChannels[i].CreateConClientListMes ( vecChanInfo ); } } @@ -882,9 +884,11 @@ void CServer::CreateAndSendChanListForAllConChannels() void CServer::CreateAndSendChanListForThisChan ( const int iCurChanID ) { // create channel list - CVector vecChanInfo ( CreateChannelList() ); + CVector vecChanInfo ( CreateChannelList() ); // now send connected channels list to the channel with the ID "iCurChanID" +// #### COMPATIBILITY OLD VERSION, TO BE REMOVED #### +vecChannels[iCurChanID].CreateConClientListNameMes ( vecChanInfo ); vecChannels[iCurChanID].CreateConClientListMes ( vecChanInfo ); } @@ -894,6 +898,7 @@ void CServer::CreateAndSendChatTextForAllConChannels ( const int iCurChanID // Create message which is sent to all connected clients ------------------- // get client name, if name is empty, use IP address instead QString ChanName = vecChannels[iCurChanID].GetName(); + if ( ChanName.isEmpty() ) { // convert IP address to text and show it @@ -904,6 +909,7 @@ void CServer::CreateAndSendChatTextForAllConChannels ( const int iCurChanID // add time and name of the client at the beginning of the message text and // use different colors QString sCurColor = vstrChatColors[iCurChanID % vstrChatColors.Size()]; + const QString strActualMessageText = "(" + QTime::currentTime().toString ( "hh:mm:ss AP" ) + ") " + ChanName + @@ -1023,8 +1029,8 @@ bool CServer::PutData ( const CVector& vecbyRecBuf, // address vecChannels[iCurChanID].SetAddress ( HostAdr ); - // reset channel name - vecChannels[iCurChanID].ResetName(); + // reset channel info + vecChannels[iCurChanID].ResetInfo(); // reset the channel gains of current channel, at the same // time reset gains of this channel ID for all other channels @@ -1111,7 +1117,7 @@ bool CServer::PutData ( const CVector& vecbyRecBuf, // was restartet, it is important that we send the channel list // at this place. vecChannels[iCurChanID].ResetTimeOutCounter(); - vecChannels[iCurChanID].CreateReqChanNameMes(); + vecChannels[iCurChanID].CreateReqChanInfoMes(); // COMPATIBILITY ISSUE // since old versions of the llcon software did not implement the channel name @@ -1170,7 +1176,7 @@ void CServer::StartStatusHTMLFileWriting ( const QString& strNewFileName, void CServer::WriteHTMLChannelList() { // create channel list - CVector vecChanInfo ( CreateChannelList() ); + CVector vecChanInfo ( CreateChannelList() ); // prepare file and stream QFile serverFileListFile ( strServerHTMLFileListName );