From 205daead99c611a36f0a685d352a665964431d98 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Tue, 10 Mar 2009 22:08:12 +0000 Subject: [PATCH] do not show last digits of IP address in case no fader tag is available for chat window and audio mixer fader --- src/audiomixerboard.cpp | 9 ++++++--- src/channel.cpp | 14 ++++++-------- src/util.h | 6 ++++++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index b9cfc86a..44ccdf12 100755 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -191,9 +191,12 @@ QString CAudioMixerBoard::GenFaderText ( CChannelShortInfo& ChanInfo ) // if text is empty, show IP address instead if ( ChanInfo.strName.isEmpty() ) { - // convert IP address to text and show it - const QHostAddress addrTest ( ChanInfo.iIpAddr ); - return addrTest.toString(); + // convert IP address to text and show it (use dummy port number + // since it is not used here) + const CHostAddress TempAddr = + CHostAddress ( QHostAddress ( ChanInfo.iIpAddr ), 0 ); + + return TempAddr.GetIpAddressStringNoLastByte(); } else { diff --git a/src/channel.cpp b/src/channel.cpp index 7076a00a..be2434b9 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -205,8 +205,8 @@ void CChannelSet::CreateAndSendChatTextForAllConChannels ( const int iCurChanID, if ( ChanName.isEmpty() ) { // convert IP address to text and show it - const QHostAddress addrTest ( vecChannels[iCurChanID].GetAddress().InetAddr ); - ChanName = addrTest.toString(); + ChanName = + vecChannels[iCurChanID].GetAddress().GetIpAddressStringNoLastByte(); } // add name of the client at the beginning of the message text and use @@ -637,12 +637,10 @@ void CChannelSet::WriteHTMLChannelList() // if text is empty, show IP address instead if ( strCurChanName.isEmpty() ) { - // convert IP address to text and show it - const QHostAddress addrTest ( vecChannels[i].GetAddress().InetAddr ); - strCurChanName = addrTest.toString(); - - // remove last digits - strCurChanName = strCurChanName.section ( ".", 0, 2 ) + ".x"; + // convert IP address to text and show it, remove last + // digits + strCurChanName = + vecChannels[i].GetAddress().GetIpAddressStringNoLastByte(); } streamFileOut << "
  • " << strCurChanName << "
  • " << endl; diff --git a/src/util.h b/src/util.h index 83df50fc..eeaa7a39 100755 --- a/src/util.h +++ b/src/util.h @@ -392,6 +392,12 @@ public: bool operator== ( const CHostAddress& CompAddr ) // compare operator { return ( ( CompAddr.InetAddr == InetAddr ) && ( CompAddr.iPort == iPort ) ); } + QString GetIpAddressStringNoLastByte() const + { + // remove the last byte of the IP address + return InetAddr.toString().section ( ".", 0, 2 ) + ".x"; + } + QHostAddress InetAddr; quint16 iPort; };