Skip to content

Commit

Permalink
Merge pull request #2 from corrados/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
ignotus666 authored Jul 8, 2020
2 parents 80d3e25 + 91d5560 commit 1df53d8
Show file tree
Hide file tree
Showing 22 changed files with 264 additions and 92 deletions.
9 changes: 4 additions & 5 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@



TODO add new register message which contains version and, e.g., max number of clients

TODO Inconsistency between Input meter and Audio mixer meter #423

TODO improve settings management -> move settings class in client/server classes, move actual settings variables
TODO store recorder settings (#313)
TODO improve interaction between use of inifile and command line parameters (edited) #120
TODO Save and restore mixer state (fader / mute / solo...) #377
(Add a save action for client and server with a keyboard shortcut #347) -> should be closed




Expand Down
31 changes: 23 additions & 8 deletions src/audiomixerboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ CChannelFader::CChannelFader ( QWidget* pNW )
pMainGrid->addWidget ( pLabelInstBox );

// reset current fader
strGroupBaseText = "Grp"; // this will most probably overwritten by SetGUIDesign()
iInstrPicFixedWidth = INVALID_INDEX; // this will most probably overwritten by SetGUIDesign()
strGroupBaseText = "Grp"; // this will most probably overwritten by SetGUIDesign()
iInstrPicMaxWidth = INVALID_INDEX; // this will most probably overwritten by SetGUIDesign()
Reset();

// add help text to controls
Expand Down Expand Up @@ -228,7 +228,7 @@ void CChannelFader::SetGUIDesign ( const EGUIDesign eNewDesign )
pcbSolo->setText ( tr ( "SOLO" ) );
strGroupBaseText = tr ( "GRP" );
plbrChannelLevel->SetLevelMeterType ( CLevelMeter::MT_LED );
iInstrPicFixedWidth = INVALID_INDEX; // no instrument picture scaling
iInstrPicMaxWidth = INVALID_INDEX; // no instrument picture scaling
break;

case GD_SLIMFADER:
Expand All @@ -243,7 +243,7 @@ void CChannelFader::SetGUIDesign ( const EGUIDesign eNewDesign )
pcbSolo->setText ( tr ( "S" ) );
strGroupBaseText = tr ( "G" );
plbrChannelLevel->SetLevelMeterType ( CLevelMeter::MT_SLIM_BAR );
iInstrPicFixedWidth = 18; // scale instrument picture to avoid enlarging the width by the picture
iInstrPicMaxWidth = 18; // scale instrument picture to avoid enlarging the width by the picture
break;

default:
Expand All @@ -259,7 +259,7 @@ void CChannelFader::SetGUIDesign ( const EGUIDesign eNewDesign )
pcbSolo->setText ( tr ( "Solo" ) );
strGroupBaseText = tr ( "Grp" );
plbrChannelLevel->SetLevelMeterType ( CLevelMeter::MT_BAR );
iInstrPicFixedWidth = INVALID_INDEX; // no instrument picture scaling
iInstrPicMaxWidth = INVALID_INDEX; // no instrument picture scaling
break;
}

Expand Down Expand Up @@ -503,7 +503,7 @@ void CChannelFader::SetGroupID ( const int iNGroupID )
void CChannelFader::UpdateGroupIDDependencies()
{
// update the group checkbox according the current group ID setting
pcbGroup->blockSignals ( true ); // make sure no signals as fired
pcbGroup->blockSignals ( true ); // make sure no signals are fired
if ( iGroupID == INVALID_INDEX )
{
pcbGroup->setCheckState ( Qt::Unchecked );
Expand All @@ -524,6 +524,21 @@ void CChannelFader::UpdateGroupIDDependencies()
pcbGroup->setText ( strGroupBaseText );
}

// if the group is disable for this fader, reset the previous fader level
if ( iGroupID == INVALID_INDEX )
{
// for the special case that the fader is all the way down, use a small
// value instead
if ( GetFaderLevel() > 0 )
{
dPreviousFaderLevel = GetFaderLevel();
}
else
{
dPreviousFaderLevel = 1; // small value
}
}

// the fader tag border color is set according to the selected group
SetupFaderTag ( cReceivedChanInfo.eSkillLevel );
}
Expand Down Expand Up @@ -616,10 +631,10 @@ void CChannelFader::SetChannelInfos ( const CChannelInfo& cChanInfo )
// set correct picture
QPixmap pixInstr ( strCurResourceRef );

if ( ( iInstrPicFixedWidth != INVALID_INDEX ) && ( pixInstr.width() > iInstrPicFixedWidth ) )
if ( ( iInstrPicMaxWidth != INVALID_INDEX ) && ( pixInstr.width() > iInstrPicMaxWidth ) )
{
// scale instrument picture on request (scale to the width with correct aspect ratio)
plblInstrument->setPixmap ( pixInstr.scaledToWidth ( iInstrPicFixedWidth, Qt::SmoothTransformation ) );
plblInstrument->setPixmap ( pixInstr.scaledToWidth ( iInstrPicMaxWidth, Qt::SmoothTransformation ) );
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/audiomixerboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class CChannelFader : public QObject
double dPreviousFaderLevel;
int iGroupID;
QString strGroupBaseText;
int iInstrPicFixedWidth;
int iInstrPicMaxWidth;

public slots:
void OnLevelValueChanged ( int value ) { SendFaderLevelToServer ( value, false ); }
Expand Down
172 changes: 170 additions & 2 deletions src/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,14 @@ CONNECTION LESS MESSAGES
necessary, that value will contain the server internal address.
- PROTMESSID_CLM_REGISTER_SERVER_EX: Register a server, providing extended server
information
+--------------------------------+-------------------------------+
| PROTMESSID_CLM_REGISTER_SERVER | PROTMESSID_CLM_VERSION_AND_OS |
+--------------------------------+-------------------------------+
- PROTMESSID_CLM_UNREGISTER_SERVER: Unregister a server
note: does not have any data -> n = 0
Expand Down Expand Up @@ -738,6 +746,10 @@ if ( rand() < ( RAND_MAX / 2 ) ) return false;
bRet = EvaluateCLRegisterServerMes ( InetAddr, vecbyMesBodyData );
break;

case PROTMESSID_CLM_REGISTER_SERVER_EX:
bRet = EvaluateCLRegisterServerExMes ( InetAddr, vecbyMesBodyData );
break;

case PROTMESSID_CLM_UNREGISTER_SERVER:
bRet = EvaluateCLUnregisterServerMes ( InetAddr );
break;
Expand Down Expand Up @@ -1466,8 +1478,8 @@ void CProtocol::CreateReqChannelLevelListMes ( const bool bRCL )
{
CVector<uint8_t> vecData ( 1 ); // 1 byte of data
int iPos = 0; // init position pointer
PutValOnStream ( vecData, iPos,
static_cast<uint32_t> ( bRCL ), 1 );

PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( bRCL ), 1 );

CreateAndSendMessage ( PROTMESSID_REQ_CHANNEL_LEVEL_LIST, vecData );
}
Expand Down Expand Up @@ -1820,6 +1832,162 @@ bool CProtocol::EvaluateCLRegisterServerMes ( const CHostAddress& InetAddr,
return false; // no error
}

void CProtocol::CreateCLRegisterServerExMes ( const CHostAddress& InetAddr,
const CHostAddress& LInetAddr,
const CServerCoreInfo& ServerInfo )
{
int iPos = 0; // init position pointer

// convert server info strings to utf-8
const QByteArray strUTF8LInetAddr = LInetAddr.InetAddr.toString().toUtf8();
const QByteArray strUTF8Name = ServerInfo.strName.toUtf8();
const QByteArray strUTF8City = ServerInfo.strCity.toUtf8();
const QByteArray strUTF8Version = QString ( VERSION ).toUtf8();

// size of current message body
const int iEntrLen =
2 /* server internal port number */ +
2 /* country */ +
1 /* maximum number of connected clients */ +
1 /* is permanent flag */ +
2 /* name utf-8 string size */ + strUTF8Name.size() +
2 /* server internal address utf-8 string size */ + strUTF8LInetAddr.size() +
2 /* city utf-8 string size */ + strUTF8City.size() +
1 /* operating system */ +
2 /* version utf-8 string size */ + strUTF8Version.size();

// build data vector
CVector<uint8_t> vecData ( iEntrLen );

// port number (2 bytes)
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( LInetAddr.iPort ), 2 );

// country (2 bytes)
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( ServerInfo.eCountry ), 2 );

// maximum number of connected clients (1 byte)
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( ServerInfo.iMaxNumClients ), 1 );

// "is permanent" flag (1 byte)
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( ServerInfo.bPermanentOnline ), 1 );

// name
PutStringUTF8OnStream ( vecData, iPos, strUTF8Name );

// server internal address (formerly unused topic)
PutStringUTF8OnStream ( vecData, iPos, strUTF8LInetAddr );

// city
PutStringUTF8OnStream ( vecData, iPos, strUTF8City );

// operating system (1 byte)
PutValOnStream ( vecData, iPos,
static_cast<uint32_t> ( COSUtil::GetOperatingSystem() ), 1 );

// version
PutStringUTF8OnStream ( vecData, iPos, strUTF8Version );

CreateAndImmSendConLessMessage ( PROTMESSID_CLM_REGISTER_SERVER_EX,
vecData,
InetAddr );
}

bool CProtocol::EvaluateCLRegisterServerExMes ( const CHostAddress& InetAddr,
const CVector<uint8_t>& vecData )
{
int iPos = 0; // init position pointer
const int iDataLen = vecData.Size();
QString sLocHost; // temp string for server internal address
CHostAddress LInetAddr;
CServerCoreInfo RecServerInfo;

// check size (the first 6 bytes)
if ( iDataLen < 6 )
{
return true; // return error code
}

// port number (2 bytes)
LInetAddr.iPort = static_cast<quint16> ( GetValFromStream ( vecData, iPos, 2 ) );

// country (2 bytes)
RecServerInfo.eCountry = static_cast<QLocale::Country> ( GetValFromStream ( vecData, iPos, 2 ) );

// maximum number of connected clients (1 byte)
RecServerInfo.iMaxNumClients = static_cast<int> ( GetValFromStream ( vecData, iPos, 1 ) );

// "is permanent" flag (1 byte)
RecServerInfo.bPermanentOnline = static_cast<bool> ( GetValFromStream ( vecData, iPos, 1 ) );

// server name
if ( GetStringFromStream ( vecData,
iPos,
MAX_LEN_SERVER_NAME,
RecServerInfo.strName ) )
{
return true; // return error code
}

// server internal address
if ( GetStringFromStream ( vecData,
iPos,
MAX_LEN_IP_ADDRESS,
sLocHost ) )
{
return true; // return error code
}

if ( sLocHost.isEmpty() )
{
// old server, empty "topic", register as local host
LInetAddr.InetAddr.setAddress ( QHostAddress::LocalHost );
}
else if ( !LInetAddr.InetAddr.setAddress ( sLocHost ) )
{
return true; // return error code
}

// server city
if ( GetStringFromStream ( vecData,
iPos,
MAX_LEN_SERVER_CITY,
RecServerInfo.strCity ) )
{
return true; // return error code
}

// check size (the next 1 byte)
if ( iDataLen < iPos + 1 )
{
return true; // return error code
}

// operating system (1 byte)
const COSUtil::EOpSystemType eOSType =
static_cast<COSUtil::EOpSystemType> ( GetValFromStream ( vecData, iPos, 1 ) );

// version text
QString strVersion;
if ( GetStringFromStream ( vecData,
iPos,
MAX_LEN_VERSION_TEXT,
strVersion ) )
{
return true; // return error code
}

// check size: all data is read, the position must now be at the end
if ( iPos != iDataLen )
{
return true; // return error code
}

// invoke message action
emit CLRegisterServerExReceived ( InetAddr, LInetAddr, RecServerInfo, eOSType, strVersion );

return false; // no error
}

void CProtocol::CreateCLUnregisterServerMes ( const CHostAddress& InetAddr )
{
CreateAndImmSendConLessMessage ( PROTMESSID_CLM_UNREGISTER_SERVER,
Expand Down
11 changes: 11 additions & 0 deletions src/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
#define PROTMESSID_CLM_REQ_CONN_CLIENTS_LIST 1014 // request the connected clients list
#define PROTMESSID_CLM_CHANNEL_LEVEL_LIST 1015 // channel level list
#define PROTMESSID_CLM_REGISTER_SERVER_RESP 1016 // status of server registration request
#define PROTMESSID_CLM_REGISTER_SERVER_EX 1017 // register server with extended information

// lengths of message as defined in protocol.cpp file
#define MESS_HEADER_LENGTH_BYTE 7 // TAG (2), ID (2), cnt (1), length (2)
Expand Down Expand Up @@ -125,6 +126,9 @@ class CProtocol : public QObject
void CreateCLRegisterServerMes ( const CHostAddress& InetAddr,
const CHostAddress& LInetAddr,
const CServerCoreInfo& ServerInfo );
void CreateCLRegisterServerExMes ( const CHostAddress& InetAddr,
const CHostAddress& LInetAddr,
const CServerCoreInfo& ServerInfo );
void CreateCLUnregisterServerMes ( const CHostAddress& InetAddr );
void CreateCLServerListMes ( const CHostAddress& InetAddr,
const CVector<CServerInfo> vecServerInfo );
Expand Down Expand Up @@ -250,6 +254,8 @@ class CProtocol : public QObject
bool EvaluateCLServerFullMes();
bool EvaluateCLRegisterServerMes ( const CHostAddress& InetAddr,
const CVector<uint8_t>& vecData );
bool EvaluateCLRegisterServerExMes ( const CHostAddress& InetAddr,
const CVector<uint8_t>& vecData );
bool EvaluateCLUnregisterServerMes ( const CHostAddress& InetAddr );
bool EvaluateCLServerListMes ( const CHostAddress& InetAddr,
const CVector<uint8_t>& vecData );
Expand Down Expand Up @@ -315,6 +321,11 @@ public slots:
void CLRegisterServerReceived ( CHostAddress InetAddr,
CHostAddress LInetAddr,
CServerCoreInfo ServerInfo );
void CLRegisterServerExReceived ( CHostAddress InetAddr,
CHostAddress LInetAddr,
CServerCoreInfo ServerInfo,
COSUtil::EOpSystemType eOSType,
QString strVersion );
void CLUnregisterServerReceived ( CHostAddress InetAddr );
void CLServerListReceived ( CHostAddress InetAddr,
CVector<CServerInfo> vecServerInfo );
Expand Down
Binary file modified src/res/translation/translation_de_DE.qm
Binary file not shown.
6 changes: 3 additions & 3 deletions src/res/translation/translation_de_DE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3220,17 +3220,17 @@
<context>
<name>QCoreApplication</name>
<message>
<location filename="../../util.cpp" line="1578"/>
<location filename="../../util.cpp" line="1585"/>
<source>, Version </source>
<translation>, Version </translation>
</message>
<message>
<location filename="../../util.cpp" line="1591"/>
<location filename="../../util.cpp" line="1598"/>
<source>Internet Jam Session Software</source>
<translation>Internet Jam Session Software</translation>
</message>
<message>
<location filename="../../util.cpp" line="1595"/>
<location filename="../../util.cpp" line="1602"/>
<source>Released under the GNU General Public License (GPL)</source>
<translation>Unter der GNU General Public License (GPL)</translation>
</message>
Expand Down
Binary file modified src/res/translation/translation_es_ES.qm
Binary file not shown.
6 changes: 3 additions & 3 deletions src/res/translation/translation_es_ES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3240,17 +3240,17 @@
<context>
<name>QCoreApplication</name>
<message>
<location filename="../../util.cpp" line="1578"/>
<location filename="../../util.cpp" line="1585"/>
<source>, Version </source>
<translation>, Versión </translation>
</message>
<message>
<location filename="../../util.cpp" line="1591"/>
<location filename="../../util.cpp" line="1598"/>
<source>Internet Jam Session Software</source>
<translation>Internet Jam Session Software</translation>
</message>
<message>
<location filename="../../util.cpp" line="1595"/>
<location filename="../../util.cpp" line="1602"/>
<source>Released under the GNU General Public License (GPL)</source>
<translation>Publicado bajo la GNU General Public License (GPL)</translation>
</message>
Expand Down
Loading

0 comments on commit 1df53d8

Please sign in to comment.