diff --git a/ChangeLog b/ChangeLog index 6121bf42..300dd097 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ - another improvement of auto jitter buffer detection in very bad network conditions +- support client operation without using a GUI frontend diff --git a/src/client.cpp b/src/client.cpp index 6c5f5149..431f8261 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -26,7 +26,8 @@ /* Implementation *************************************************************/ -CClient::CClient ( const quint16 iPortNumber ) : +CClient::CClient ( const quint16 iPortNumber, + const QString& strConnOnStartupAddress ) : vstrIPAddress ( MAX_NUM_SERVER_ADDR_ITEMS, "" ), ChannelInfo (), vecStoredFaderTags ( MAX_NUM_STORED_FADER_SETTINGS, "" ), @@ -227,6 +228,13 @@ QObject::connect ( &Channel, SIGNAL ( OpusSupported() ), // start the socket (it is important to start the socket after all // initializations and connections) Socket.Start(); + + // do an immediate start if a server address is given + if ( !strConnOnStartupAddress.isEmpty() ) + { + SetServerAddr ( strConnOnStartupAddress ); + Start(); + } } void CClient::OnSendProtMessage ( CVector vecMessage ) diff --git a/src/client.h b/src/client.h index 521013e3..5a1d1e39 100755 --- a/src/client.h +++ b/src/client.h @@ -114,7 +114,8 @@ class CClient : public QObject Q_OBJECT public: - CClient ( const quint16 iPortNumber ); + CClient ( const quint16 iPortNumber, + const QString& strConnOnStartupAddress ); void Start(); void Stop(); diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp index 99bbd0c8..985130db 100755 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -28,7 +28,7 @@ /* Implementation *************************************************************/ CClientDlg::CClientDlg ( CClient* pNCliP, CSettings* pNSetP, - const bool bNewConnectOnStartup, + const QString& strConnOnStartupAddress, const bool bNewShowComplRegConnList, const bool bShowAnalyzerConsole, QWidget* parent, @@ -225,19 +225,11 @@ CClientDlg::CClientDlg ( CClient* pNCliP, // Connect on startup ------------------------------------------------------ - if ( bNewConnectOnStartup ) + if ( !strConnOnStartupAddress.isEmpty() ) { - // per definition use the last connection (first entry in the - // stored address list) - const QString strSelectedAddress = pClient->vstrIPAddress[0]; - - // only if address is not empty, start the client - if ( !strSelectedAddress.isEmpty() ) - { - // initiate connection (always show the address in the mixer board - // (no alias)) - Connect ( strSelectedAddress, strSelectedAddress ); - } + // initiate connection (always show the address in the mixer board + // (no alias)) + Connect ( strConnOnStartupAddress, strConnOnStartupAddress ); } @@ -1001,7 +993,10 @@ void CClientDlg::Connect ( const QString& strSelectedAddress, // running state but show error message try { - pClient->Start(); + if ( !pClient->IsRunning() ) + { + pClient->Start(); + } } catch ( CGenErr generr ) diff --git a/src/clientdlg.h b/src/clientdlg.h index deaa33c7..6d4508ef 100755 --- a/src/clientdlg.h +++ b/src/clientdlg.h @@ -71,7 +71,7 @@ class CClientDlg : public QDialog, private Ui_CClientDlgBase public: CClientDlg ( CClient* pNCliP, CSettings* pNSetP, - const bool bNewConnectOnStartup, + const QString& strConnOnStartupAddress, const bool bNewShowComplRegConnList, const bool bShowAnalyzerConsole, QWidget* parent = 0, diff --git a/src/main.cpp b/src/main.cpp index f50f5301..08f43bd1 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -56,13 +56,13 @@ int main ( int argc, char** argv ) bool bIsClient = true; bool bUseGUI = true; bool bStartMinimized = false; - bool bConnectOnStartup = false; bool bShowComplRegConnList = false; bool bShowAnalyzerConsole = false; bool bCentServPingServerInList = false; int iNumServerChannels = DEFAULT_USED_NUM_CHANNELS; quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER; ELicenceType eLicenceType = LT_NO_LICENCE; + QString strConnOnStartupAddress = ""; QString strIniFileName = ""; QString strHTMLStatusFileName = ""; QString strServerName = ""; @@ -324,13 +324,16 @@ int main ( int argc, char** argv ) // Connect on startup -------------------------------------------------- - if ( GetFlagArgument ( argv, - i, - "-c", - "--connect" ) ) + if ( GetStringArgument ( tsConsole, + argc, + argv, + i, + "-c", + "--connect", + strArgument ) ) { - bConnectOnStartup = true; - tsConsole << "- connect on startup enabled" << endl; + strConnOnStartupAddress = strArgument; + tsConsole << "- connect on startup to address: " << strConnOnStartupAddress << endl; continue; } @@ -397,28 +400,39 @@ int main ( int argc, char** argv ) { // Client: // actual client object - CClient Client ( iPortNumber ); + CClient Client ( iPortNumber, + strConnOnStartupAddress ); // load settings from init-file CSettings Settings ( &Client, strIniFileName ); Settings.Load(); - // GUI object - CClientDlg ClientDlg ( &Client, - &Settings, - bConnectOnStartup, - bShowComplRegConnList, - bShowAnalyzerConsole, - 0, - Qt::Window ); + if ( bUseGUI ) + { + // GUI object + CClientDlg ClientDlg ( &Client, + &Settings, + strConnOnStartupAddress, + bShowComplRegConnList, + bShowAnalyzerConsole, + 0, + Qt::Window ); - // set main window - pMainWindow = &ClientDlg; - pApp = &app; // Needed for post-event routine + // set main window + pMainWindow = &ClientDlg; + pApp = &app; // needed for post-event routine - // show dialog - ClientDlg.show(); - app.exec(); + // show dialog + ClientDlg.show(); + app.exec(); + } + else + { + // only start application without using the GUI + tsConsole << CAboutDlg::GetVersionAndNameStr ( false ) << endl; + + app.exec(); + } } else { @@ -514,8 +528,8 @@ QString UsageArguments ( char **argv ) "\nRecognized options:\n" " -a, --servername server name, required for HTML status (server\n" " only)\n" - " -c, --connect connect to last server on startup (client\n" - " only)\n" + " -c, --connect connect to given server address on startup\n" + " (client only)\n" " -e, --centralserver address of the central server (server only)\n" " -g, --pingservers ping servers in list to keep NAT port open\n" " (central server only)\n"