From b1c97c2d36d36442d29f192a1961de00451a78b2 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Fri, 5 Jun 2020 14:22:44 +0200 Subject: [PATCH] avoid showing IP address if no name in the musician profile is given #316 --- ChangeLog | 2 ++ src/audiomixerboard.cpp | 2 +- src/connectdlg.cpp | 2 +- src/server.cpp | 20 +------------------- src/settings.cpp | 3 ++- src/util.h | 29 +++++------------------------ 6 files changed, 12 insertions(+), 46 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8009c402..fe6fb676 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,8 @@ - added check in acknowledge message, coded by atsampson (#302) +- avoid showing IP address if no name in the musician profile is given #316 + - bug fix: on MacOS declare an activity to ensure the process doesn't get throttled by OS level Nap, Sleep, and Thread Priority systems, coded by AronVietti (#23) diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index b54db3ec..d3c30bd4 100644 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -439,7 +439,7 @@ void CChannelFader::SetText ( const CChannelInfo& ChanInfo ) // break text at predefined position const int iBreakPos = MAX_LEN_FADER_TAG / 2; - QString strModText = ChanInfo.GenNameForDisplay(); + QString strModText = ChanInfo.strName; if ( strModText.length() > iBreakPos ) { diff --git a/src/connectdlg.cpp b/src/connectdlg.cpp index 31472392..a711f40a 100755 --- a/src/connectdlg.cpp +++ b/src/connectdlg.cpp @@ -430,7 +430,7 @@ void CConnectDlg::SetConnClientsList ( const CHostAddress& InetAddr, pNewChildListViewItem->setFirstColumnSpanned ( true ); // set the clients name - QString sClientText = vecChanInfo[i].GenNameForDisplay(); + QString sClientText = vecChanInfo[i].strName; // set the icon: country flag has priority over instrument bool bCountryFlagIsUsed = false; diff --git a/src/server.cpp b/src/server.cpp index 4ee8533e..90974f23 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -1303,13 +1303,6 @@ void CServer::CreateAndSendChatTextForAllConChannels ( const int iCurChanID // 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 - ChanName = vecChannels[iCurChanID].GetAddress(). - toString ( CHostAddress::SM_IP_NO_LAST_BYTE ); - } - // add time and name of the client at the beginning of the message text and // use different colors QString sCurColor = vstrChatColors[iCurChanID % vstrChatColors.Size()]; @@ -1552,18 +1545,7 @@ void CServer::WriteHTMLChannelList() { if ( vecChannels[i].IsConnected() ) { - QString strCurChanName = vecChannels[i].GetName(); - - // if text is empty, show IP address instead - if ( strCurChanName.isEmpty() ) - { - // convert IP address to text and show it, remove last - // digits - strCurChanName = vecChannels[i].GetAddress(). - toString ( CHostAddress::SM_IP_NO_LAST_BYTE ); - } - - streamFileOut << "
  • " << strCurChanName << "
  • " << endl; + streamFileOut << "
  • " << vecChannels[i].GetName() << "
  • " << endl; } } } diff --git a/src/settings.cpp b/src/settings.cpp index b115db77..e1db2c2a 100755 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -125,7 +125,8 @@ void CSettings::Load() // name pClient->ChannelInfo.strName = FromBase64ToString ( - GetIniSetting ( IniXMLDocument, "client", "name_base64" ) ); + GetIniSetting ( IniXMLDocument, "client", "name_base64", + ToBase64 ( QCoreApplication::translate ( "CMusProfDlg", "No Name" ) ) ) ); // instrument if ( GetNumericIniSet ( IniXMLDocument, "client", "instrument", diff --git a/src/util.h b/src/util.h index ebeeb05e..44005b43 100755 --- a/src/util.h +++ b/src/util.h @@ -836,11 +836,11 @@ class CChannelCoreInfo { public: CChannelCoreInfo() : - strName ( "" ), - eCountry ( QLocale::AnyCountry ), - strCity ( "" ), - iInstrument ( CInstPictures::GetNotUsedInstrument() ), - eSkillLevel ( SL_NOT_SET ) {} + strName ( "" ), + eCountry ( QLocale::AnyCountry ), + strCity ( "" ), + iInstrument ( CInstPictures::GetNotUsedInstrument() ), + eSkillLevel ( SL_NOT_SET ) {} CChannelCoreInfo ( const QString NsName, const QLocale::Country& NeCountry, @@ -917,25 +917,6 @@ public: iChanID ( NiID ), iIpAddr ( NiIP ) {} - QString GenNameForDisplay() const - { - // if text is empty, show IP address instead - if ( strName.isEmpty() ) - { - // convert IP address to text and show it (use dummy port number - // since it is not used here) - const CHostAddress TempAddr = - CHostAddress ( QHostAddress ( iIpAddr ), 0 ); - - return TempAddr.toString ( CHostAddress::SM_IP_NO_LAST_BYTE ); - } - else - { - // show name of channel - return strName; - } - } - // ID of the channel int iChanID;