diff --git a/src/channel.cpp b/src/channel.cpp index 33e6260a..97476dec 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -115,19 +115,6 @@ void CChannelSet::CreateAndSendChanListForAllConChannels() } } -void CChannelSet::CreateAndSendChatTextForAllConChannels ( const QString& strChatText ) -{ - // send chat text to all connected clients - for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) - { - if ( vecChannels[i].IsConnected() ) - { - // send message - vecChannels[i].CreateChatTextMes ( strChatText ); - } - } -} - void CChannelSet::CreateAndSendChanListForAllExceptThisChan ( const int iCurChanID ) { // create channel list @@ -154,6 +141,35 @@ void CChannelSet::CreateAndSendChanListForThisChan ( const int iCurChanID ) vecChannels[iCurChanID].CreateConClientListMes ( vecChanInfo ); } +void CChannelSet::CreateAndSendChatTextForAllConChannels ( const int iCurChanID, + const QString& strChatText ) +{ + // 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 + const QHostAddress addrTest ( vecChannels[iCurChanID].GetAddress().InetAddr ); + ChanName = addrTest.toString(); + } + + // add name of the client at the beginning of the message text + const QString strActualMessageText = + "<" + ChanName + "> " + strChatText; + + + // send chat text to all connected clients --------------------------------- + for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) + { + if ( vecChannels[i].IsConnected() ) + { + // send message + vecChannels[i].CreateChatTextMes ( strActualMessageText ); + } + } +} + int CChannelSet::GetFreeChan() { // look for a free channel diff --git a/src/channel.h b/src/channel.h index 3175c564..99f6fef6 100755 --- a/src/channel.h +++ b/src/channel.h @@ -239,7 +239,7 @@ protected: void CreateAndSendChanListForAllConChannels(); void CreateAndSendChanListForAllExceptThisChan ( const int iCurChanID ); void CreateAndSendChanListForThisChan ( const int iCurChanID ); - void CreateAndSendChatTextForAllConChannels ( const QString& strChatText ); + void CreateAndSendChatTextForAllConChannels ( const int iCurChanID, const QString& strChatText ); /* do not use the vector class since CChannel does not have appropriate copy constructor/operator */ @@ -250,19 +250,19 @@ public slots: // CODE TAG: MAX_NUM_CHANNELS_TAG // make sure we have MAX_NUM_CHANNELS connections!!! // send message - void OnSendProtMessCh0(CVector mess) {emit MessReadyForSending(0,mess);} - void OnSendProtMessCh1(CVector mess) {emit MessReadyForSending(1,mess);} - void OnSendProtMessCh2(CVector mess) {emit MessReadyForSending(2,mess);} - void OnSendProtMessCh3(CVector mess) {emit MessReadyForSending(3,mess);} - void OnSendProtMessCh4(CVector mess) {emit MessReadyForSending(4,mess);} - void OnSendProtMessCh5(CVector mess) {emit MessReadyForSending(5,mess);} + void OnSendProtMessCh0 ( CVector mess ) {emit MessReadyForSending ( 0, mess ); } + void OnSendProtMessCh1 ( CVector mess ) {emit MessReadyForSending ( 1, mess ); } + void OnSendProtMessCh2 ( CVector mess ) {emit MessReadyForSending ( 2, mess ); } + void OnSendProtMessCh3 ( CVector mess ) {emit MessReadyForSending ( 3, mess ); } + void OnSendProtMessCh4 ( CVector mess ) {emit MessReadyForSending ( 4, mess ); } + void OnSendProtMessCh5 ( CVector mess ) {emit MessReadyForSending ( 5, mess ); } - void OnNewConnectionCh0() {vecChannels[0].CreateReqJitBufMes();} - void OnNewConnectionCh1() {vecChannels[1].CreateReqJitBufMes();} - void OnNewConnectionCh2() {vecChannels[2].CreateReqJitBufMes();} - void OnNewConnectionCh3() {vecChannels[3].CreateReqJitBufMes();} - void OnNewConnectionCh4() {vecChannels[4].CreateReqJitBufMes();} - void OnNewConnectionCh5() {vecChannels[5].CreateReqJitBufMes();} + void OnNewConnectionCh0() { vecChannels[0].CreateReqJitBufMes(); } + void OnNewConnectionCh1() { vecChannels[1].CreateReqJitBufMes(); } + void OnNewConnectionCh2() { vecChannels[2].CreateReqJitBufMes(); } + void OnNewConnectionCh3() { vecChannels[3].CreateReqJitBufMes(); } + void OnNewConnectionCh4() { vecChannels[4].CreateReqJitBufMes(); } + void OnNewConnectionCh5() { vecChannels[5].CreateReqJitBufMes(); } void OnReqConnClientsListCh0() { CreateAndSendChanListForThisChan ( 0 ); } void OnReqConnClientsListCh1() { CreateAndSendChanListForThisChan ( 1 ); } @@ -278,12 +278,12 @@ public slots: void OnNameHasChangedCh4() { CreateAndSendChanListForAllConChannels(); } void OnNameHasChangedCh5() { CreateAndSendChanListForAllConChannels(); } - void OnChatTextReceivedCh0(QString strChatText) { CreateAndSendChatTextForAllConChannels(strChatText); } - void OnChatTextReceivedCh1(QString strChatText) { CreateAndSendChatTextForAllConChannels(strChatText); } - void OnChatTextReceivedCh2(QString strChatText) { CreateAndSendChatTextForAllConChannels(strChatText); } - void OnChatTextReceivedCh3(QString strChatText) { CreateAndSendChatTextForAllConChannels(strChatText); } - void OnChatTextReceivedCh4(QString strChatText) { CreateAndSendChatTextForAllConChannels(strChatText); } - void OnChatTextReceivedCh5(QString strChatText) { CreateAndSendChatTextForAllConChannels(strChatText); } + void OnChatTextReceivedCh0 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 0, strChatText ); } + void OnChatTextReceivedCh1 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 1, strChatText ); } + void OnChatTextReceivedCh2 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 2, strChatText ); } + void OnChatTextReceivedCh3 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 3, strChatText ); } + void OnChatTextReceivedCh4 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 4, strChatText ); } + void OnChatTextReceivedCh5 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 5, strChatText ); } signals: void MessReadyForSending ( int iChID, CVector vecMessage ); diff --git a/src/chatdlgbase.ui b/src/chatdlgbase.ui index 374eba4f..52a4fb45 100755 --- a/src/chatdlgbase.ui +++ b/src/chatdlgbase.ui @@ -29,7 +29,11 @@ - + + + 255 + +