added a command line argument, some code style changes
This commit is contained in:
parent
bebe50aa55
commit
74ac1d075f
9 changed files with 64 additions and 50 deletions
|
@ -90,7 +90,7 @@ CChannelFader::CChannelFader ( QWidget* pNW,
|
||||||
pLabel->setAccessibleName ( "Mixer level label (fader tag)" );
|
pLabel->setAccessibleName ( "Mixer level label (fader tag)" );
|
||||||
|
|
||||||
|
|
||||||
// connections -------------------------------------------------------------
|
// Connections -------------------------------------------------------------
|
||||||
QObject::connect ( pFader, SIGNAL ( valueChanged ( int ) ),
|
QObject::connect ( pFader, SIGNAL ( valueChanged ( int ) ),
|
||||||
this, SLOT ( OnGainValueChanged ( int ) ) );
|
this, SLOT ( OnGainValueChanged ( int ) ) );
|
||||||
|
|
||||||
|
@ -299,7 +299,7 @@ CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent, Qt::WindowFlags ) :
|
||||||
pMainLayout->addItem ( new QSpacerItem ( 0, 0, QSizePolicy::Expanding ) );
|
pMainLayout->addItem ( new QSpacerItem ( 0, 0, QSizePolicy::Expanding ) );
|
||||||
|
|
||||||
|
|
||||||
// connections -------------------------------------------------------------
|
// Connections -------------------------------------------------------------
|
||||||
// CODE TAG: MAX_NUM_CHANNELS_TAG
|
// CODE TAG: MAX_NUM_CHANNELS_TAG
|
||||||
// make sure we have MAX_NUM_CHANNELS connections!!!
|
// make sure we have MAX_NUM_CHANNELS connections!!!
|
||||||
QObject::connect ( vecpChanFader[0], SIGNAL ( gainValueChanged ( double ) ), this, SLOT ( OnGainValueChangedCh0 ( double ) ) );
|
QObject::connect ( vecpChanFader[0], SIGNAL ( gainValueChanged ( double ) ), this, SLOT ( OnGainValueChangedCh0 ( double ) ) );
|
||||||
|
|
|
@ -53,7 +53,7 @@ CChannel::CChannel ( const bool bNIsServer ) :
|
||||||
ResetName();
|
ResetName();
|
||||||
|
|
||||||
|
|
||||||
// connections -------------------------------------------------------------
|
// Connections -------------------------------------------------------------
|
||||||
QObject::connect ( &Protocol,
|
QObject::connect ( &Protocol,
|
||||||
SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ),
|
SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ),
|
||||||
this, SLOT ( OnSendProtMessage ( CVector<uint8_t> ) ) );
|
this, SLOT ( OnSendProtMessage ( CVector<uint8_t> ) ) );
|
||||||
|
@ -553,7 +553,7 @@ int CChannel::GetUploadRateKbps()
|
||||||
// CConnectionLessChannel implementation ***************************************
|
// CConnectionLessChannel implementation ***************************************
|
||||||
CConnectionLessChannel::CConnectionLessChannel()
|
CConnectionLessChannel::CConnectionLessChannel()
|
||||||
{
|
{
|
||||||
// connections -------------------------------------------------------------
|
// Connections -------------------------------------------------------------
|
||||||
QObject::connect ( &Protocol,
|
QObject::connect ( &Protocol,
|
||||||
SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector<uint8_t> ) ),
|
SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector<uint8_t> ) ),
|
||||||
SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector<uint8_t> ) ) );
|
SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector<uint8_t> ) ) );
|
||||||
|
|
|
@ -83,7 +83,7 @@ CClient::CClient ( const quint16 iPortNumber ) :
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// connections -------------------------------------------------------------
|
// Connections -------------------------------------------------------------
|
||||||
// connection for protocol
|
// connection for protocol
|
||||||
QObject::connect ( &Channel,
|
QObject::connect ( &Channel,
|
||||||
SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ),
|
SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ),
|
||||||
|
|
|
@ -31,7 +31,7 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
|
||||||
{
|
{
|
||||||
setupUi ( this );
|
setupUi ( this );
|
||||||
|
|
||||||
// add help text to controls -----------------------------------------------
|
// Add help text to controls -----------------------------------------------
|
||||||
// jitter buffer
|
// jitter buffer
|
||||||
QString strJitterBufferSize = tr ( "<b>Jitter Buffer Size:</b> The jitter "
|
QString strJitterBufferSize = tr ( "<b>Jitter Buffer Size:</b> The jitter "
|
||||||
"buffer compensates for network and sound card timing jitters. The "
|
"buffer compensates for network and sound card timing jitters. The "
|
||||||
|
|
|
@ -33,7 +33,7 @@ CConnectDlg::CConnectDlg ( CClient* pNCliP, QWidget* parent,
|
||||||
setupUi ( this );
|
setupUi ( this );
|
||||||
|
|
||||||
|
|
||||||
// add help text to controls -----------------------------------------------
|
// Add help text to controls -----------------------------------------------
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
|
||||||
{
|
{
|
||||||
setupUi ( this );
|
setupUi ( this );
|
||||||
|
|
||||||
// add help text to controls -----------------------------------------------
|
// Add help text to controls -----------------------------------------------
|
||||||
// input level meter
|
// input level meter
|
||||||
QString strInpLevH = tr ( "<b>Input Level Meter:</b> The input level "
|
QString strInpLevH = tr ( "<b>Input Level Meter:</b> The input level "
|
||||||
"indicators show the current input level of the two stereo channels "
|
"indicators show the current input level of the two stereo channels "
|
||||||
|
|
82
src/main.cpp
82
src/main.cpp
|
@ -49,19 +49,21 @@ int main ( int argc, char** argv )
|
||||||
bool bUseGUI = true;
|
bool bUseGUI = true;
|
||||||
bool bConnectOnStartup = false;
|
bool bConnectOnStartup = false;
|
||||||
bool bDisalbeLEDs = false;
|
bool bDisalbeLEDs = false;
|
||||||
|
bool bIsCentralServer = false;
|
||||||
quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER;
|
quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER;
|
||||||
std::string strIniFileName = "";
|
std::string strIniFileName = "";
|
||||||
std::string strHTMLStatusFileName = "";
|
std::string strHTMLStatusFileName = "";
|
||||||
std::string strServerName = "";
|
std::string strServerName = "";
|
||||||
std::string strLoggingFileName = "";
|
std::string strLoggingFileName = "";
|
||||||
std::string strHistoryFileName = "";
|
std::string strHistoryFileName = "";
|
||||||
|
std::string strCentralServer = "";
|
||||||
|
|
||||||
// QT docu: argv()[0] is the program name, argv()[1] is the first
|
// QT docu: argv()[0] is the program name, argv()[1] is the first
|
||||||
// argument and argv()[argc()-1] is the last argument.
|
// argument and argv()[argc()-1] is the last argument.
|
||||||
// Start with first argument, therefore "i = 1"
|
// Start with first argument, therefore "i = 1"
|
||||||
for ( int i = 1; i < argc; i++ )
|
for ( int i = 1; i < argc; i++ )
|
||||||
{
|
{
|
||||||
// server mode flag ----------------------------------------------------
|
// Server mode flag ----------------------------------------------------
|
||||||
if ( GetFlagArgument ( argv, i, "-s", "--server" ) )
|
if ( GetFlagArgument ( argv, i, "-s", "--server" ) )
|
||||||
{
|
{
|
||||||
bIsClient = false;
|
bIsClient = false;
|
||||||
|
@ -70,7 +72,7 @@ int main ( int argc, char** argv )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// use GUI flag --------------------------------------------------------
|
// Use GUI flag --------------------------------------------------------
|
||||||
if ( GetFlagArgument ( argv, i, "-n", "--nogui" ) )
|
if ( GetFlagArgument ( argv, i, "-n", "--nogui" ) )
|
||||||
{
|
{
|
||||||
bUseGUI = false;
|
bUseGUI = false;
|
||||||
|
@ -79,7 +81,7 @@ int main ( int argc, char** argv )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// disable LEDs flag ---------------------------------------------------
|
// Disable LEDs flag ---------------------------------------------------
|
||||||
if ( GetFlagArgument ( argv, i, "-d", "--disableleds" ) )
|
if ( GetFlagArgument ( argv, i, "-d", "--disableleds" ) )
|
||||||
{
|
{
|
||||||
bDisalbeLEDs = true;
|
bDisalbeLEDs = true;
|
||||||
|
@ -88,7 +90,7 @@ int main ( int argc, char** argv )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// use logging ---------------------------------------------------------
|
// Use logging ---------------------------------------------------------
|
||||||
if ( GetStringArgument ( argc, argv, i, "-l", "--log", strArgument ) )
|
if ( GetStringArgument ( argc, argv, i, "-l", "--log", strArgument ) )
|
||||||
{
|
{
|
||||||
strLoggingFileName = strArgument;
|
strLoggingFileName = strArgument;
|
||||||
|
@ -97,7 +99,7 @@ int main ( int argc, char** argv )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// port number ---------------------------------------------------------
|
// Port number ---------------------------------------------------------
|
||||||
if ( GetNumericArgument ( argc, argv, i, "-p", "--port",
|
if ( GetNumericArgument ( argc, argv, i, "-p", "--port",
|
||||||
0, 65535, rDbleArgument ) )
|
0, 65535, rDbleArgument ) )
|
||||||
{
|
{
|
||||||
|
@ -132,7 +134,16 @@ int main ( int argc, char** argv )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// initialization file -------------------------------------------------
|
// Central server ------------------------------------------------------
|
||||||
|
if ( GetStringArgument ( argc, argv, i, "-e", "--centralserver", strArgument ) )
|
||||||
|
{
|
||||||
|
strCentralServer = strArgument;
|
||||||
|
cout << "- central server: " << strCentralServer << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Initialization file -------------------------------------------------
|
||||||
if ( GetStringArgument ( argc, argv, i, "-i", "--inifile", strArgument ) )
|
if ( GetStringArgument ( argc, argv, i, "-i", "--inifile", strArgument ) )
|
||||||
{
|
{
|
||||||
strIniFileName = strArgument;
|
strIniFileName = strArgument;
|
||||||
|
@ -141,7 +152,7 @@ int main ( int argc, char** argv )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// connect on startup --------------------------------------------------
|
// Connect on startup --------------------------------------------------
|
||||||
if ( GetFlagArgument ( argv, i, "-c", "--connect" ) )
|
if ( GetFlagArgument ( argv, i, "-c", "--connect" ) )
|
||||||
{
|
{
|
||||||
bConnectOnStartup = true;
|
bConnectOnStartup = true;
|
||||||
|
@ -150,7 +161,7 @@ int main ( int argc, char** argv )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// help (usage) flag ---------------------------------------------------
|
// Help (usage) flag ---------------------------------------------------
|
||||||
if ( ( !strcmp ( argv[i], "--help" ) ) ||
|
if ( ( !strcmp ( argv[i], "--help" ) ) ||
|
||||||
( !strcmp ( argv[i], "-h" ) ) || ( !strcmp ( argv[i], "-?" ) ) )
|
( !strcmp ( argv[i], "-h" ) ) || ( !strcmp ( argv[i], "-?" ) ) )
|
||||||
{
|
{
|
||||||
|
@ -159,7 +170,7 @@ int main ( int argc, char** argv )
|
||||||
exit ( 1 );
|
exit ( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// unknown option ------------------------------------------------------
|
// Unknown option ------------------------------------------------------
|
||||||
cerr << argv[0] << ": ";
|
cerr << argv[0] << ": ";
|
||||||
cerr << "Unknown option '" << argv[i] << "' -- use '--help' for help"
|
cerr << "Unknown option '" << argv[i] << "' -- use '--help' for help"
|
||||||
<< endl;
|
<< endl;
|
||||||
|
@ -171,6 +182,15 @@ int main ( int argc, char** argv )
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// per definition: if we are in server mode and the central server address
|
||||||
|
// is the localhost address, we are in central server mode
|
||||||
|
if ( !bIsClient && !strCentralServer.empty() )
|
||||||
|
{
|
||||||
|
bIsCentralServer =
|
||||||
|
( !strCentralServer.compare ( "localhost" ) ||
|
||||||
|
!strCentralServer.compare ( "127.0.0.1" ) );
|
||||||
|
}
|
||||||
|
|
||||||
// Application object
|
// Application object
|
||||||
QApplication app ( argc, argv, bUseGUI );
|
QApplication app ( argc, argv, bUseGUI );
|
||||||
|
|
||||||
|
@ -201,18 +221,7 @@ int main ( int argc, char** argv )
|
||||||
{
|
{
|
||||||
if ( bIsClient )
|
if ( bIsClient )
|
||||||
{
|
{
|
||||||
|
// Client:
|
||||||
/*
|
|
||||||
// TEST run client and server at the same time
|
|
||||||
CServer Server ( strLoggingFileName.c_str(),
|
|
||||||
iPortNumber,
|
|
||||||
strHTMLStatusFileName.c_str(),
|
|
||||||
strHistoryFileName.c_str(),
|
|
||||||
strServerName.c_str() );
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// client
|
|
||||||
// actual client object
|
// actual client object
|
||||||
CClient Client ( iPortNumber );
|
CClient Client ( iPortNumber );
|
||||||
|
|
||||||
|
@ -250,7 +259,7 @@ CServer Server ( strLoggingFileName.c_str(),
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// server
|
// Server:
|
||||||
// actual server object
|
// actual server object
|
||||||
|
|
||||||
// TODO use QString
|
// TODO use QString
|
||||||
|
@ -259,7 +268,9 @@ CServer Server ( strLoggingFileName.c_str(),
|
||||||
iPortNumber,
|
iPortNumber,
|
||||||
strHTMLStatusFileName.c_str(),
|
strHTMLStatusFileName.c_str(),
|
||||||
strHistoryFileName.c_str(),
|
strHistoryFileName.c_str(),
|
||||||
strServerName.c_str() );
|
strServerName.c_str(),
|
||||||
|
bIsCentralServer,
|
||||||
|
strCentralServer.c_str() );
|
||||||
|
|
||||||
if ( bUseGUI )
|
if ( bUseGUI )
|
||||||
{
|
{
|
||||||
|
@ -313,21 +324,20 @@ std::string UsageArguments ( char **argv )
|
||||||
"Usage: " + std::string ( argv[0] ) + " [option] [argument]\n"
|
"Usage: " + std::string ( argv[0] ) + " [option] [argument]\n"
|
||||||
"Recognized options:\n"
|
"Recognized options:\n"
|
||||||
" -s, --server start server\n"
|
" -s, --server start server\n"
|
||||||
" -n, --nogui disable GUI (only avaiable for server)\n"
|
" -n, --nogui disable GUI (server only)\n"
|
||||||
" -l, --log enable logging, set file name\n"
|
" -l, --log enable logging, set file name\n"
|
||||||
" -i, --inifile initialization file name (only available for\n"
|
" -i, --inifile initialization file name (client only)\n"
|
||||||
" client)\n"
|
" -p, --port local port number (server only)\n"
|
||||||
" -p, --port local port number (only avaiable for server)\n"
|
" -m, --htmlstatus enable HTML status file, set file name (server\n"
|
||||||
" -m, --htmlstatus enable HTML status file, set file name (only\n"
|
" only)\n"
|
||||||
" available for server)\n"
|
" -a, --servername server name, required for HTML status (server\n"
|
||||||
" -a, --servername server name required for HTML status (only\n"
|
" only)\n"
|
||||||
" available for server)\n"
|
|
||||||
" -y, --history enable connection history and set file\n"
|
" -y, --history enable connection history and set file\n"
|
||||||
" name (only available for server)\n"
|
" name (server only)\n"
|
||||||
" -c, --connect connect to last server on startup (only\n"
|
" -e, --centralserver address of the central server (server only)\n"
|
||||||
" available for client)\n"
|
" -c, --connect connect to last server on startup (client\n"
|
||||||
" -d, --disableleds disable LEDs in main window (only available\n"
|
" only)\n"
|
||||||
" for client)\n"
|
" -d, --disableleds disable LEDs in main window (client only)\n"
|
||||||
" -h, -?, --help this help text\n"
|
" -h, -?, --help this help text\n"
|
||||||
"Example: " + std::string ( argv[0] ) + " -l -inifile myinifile.ini\n";
|
"Example: " + std::string ( argv[0] ) + " -l -inifile myinifile.ini\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,7 +239,8 @@ CProtocol::CProtocol()
|
||||||
{
|
{
|
||||||
Reset();
|
Reset();
|
||||||
|
|
||||||
// connections
|
|
||||||
|
// Connections -------------------------------------------------------------
|
||||||
QObject::connect ( &TimerSendMess, SIGNAL ( timeout() ),
|
QObject::connect ( &TimerSendMess, SIGNAL ( timeout() ),
|
||||||
this, SLOT ( OnTimerSendMess() ) );
|
this, SLOT ( OnTimerSendMess() ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,9 +168,12 @@ CServer::CServer ( const QString& strLoggingFileName,
|
||||||
const quint16 iPortNumber,
|
const quint16 iPortNumber,
|
||||||
const QString& strHTMLStatusFileName,
|
const QString& strHTMLStatusFileName,
|
||||||
const QString& strHistoryFileName,
|
const QString& strHistoryFileName,
|
||||||
const QString& strServerNameForHTMLStatusFile ) :
|
const QString& strServerNameForHTMLStatusFile,
|
||||||
|
const bool bIsCentralServer,
|
||||||
|
const QString& strCentralServer ) :
|
||||||
Socket ( this, iPortNumber ),
|
Socket ( this, iPortNumber ),
|
||||||
bWriteStatusHTMLFile ( false )
|
bWriteStatusHTMLFile ( false ),
|
||||||
|
ServerListManager ( bIsCentralServer ) // enable server list for central server
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -267,7 +270,7 @@ CServer::CServer ( const QString& strLoggingFileName,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// connections -------------------------------------------------------------
|
// Connections -------------------------------------------------------------
|
||||||
// connect timer timeout signal
|
// connect timer timeout signal
|
||||||
QObject::connect ( &HighPrecisionTimer, SIGNAL ( timeout() ),
|
QObject::connect ( &HighPrecisionTimer, SIGNAL ( timeout() ),
|
||||||
this, SLOT ( OnTimer() ) );
|
this, SLOT ( OnTimer() ) );
|
||||||
|
@ -804,7 +807,7 @@ void CServer::CreateAndSendChanListForThisChan ( const int iCurChanID )
|
||||||
void CServer::CreateAndSendChatTextForAllConChannels ( const int iCurChanID,
|
void CServer::CreateAndSendChatTextForAllConChannels ( const int iCurChanID,
|
||||||
const QString& strChatText )
|
const QString& strChatText )
|
||||||
{
|
{
|
||||||
// create message which is sent to all connected clients -------------------
|
// Create message which is sent to all connected clients -------------------
|
||||||
// get client name, if name is empty, use IP address instead
|
// get client name, if name is empty, use IP address instead
|
||||||
QString ChanName = vecChannels[iCurChanID].GetName();
|
QString ChanName = vecChannels[iCurChanID].GetName();
|
||||||
if ( ChanName.isEmpty() )
|
if ( ChanName.isEmpty() )
|
||||||
|
@ -823,7 +826,7 @@ void CServer::CreateAndSendChatTextForAllConChannels ( const int iCurChanID,
|
||||||
"</b></font> " + strChatText;
|
"</b></font> " + strChatText;
|
||||||
|
|
||||||
|
|
||||||
// send chat text to all connected clients ---------------------------------
|
// Send chat text to all connected clients ---------------------------------
|
||||||
for ( int i = 0; i < USED_NUM_CHANNELS; i++ )
|
for ( int i = 0; i < USED_NUM_CHANNELS; i++ )
|
||||||
{
|
{
|
||||||
if ( vecChannels[i].IsConnected() )
|
if ( vecChannels[i].IsConnected() )
|
||||||
|
|
Loading…
Add table
Reference in a new issue