2011-04-25 15:25:33 +02:00
|
|
|
/******************************************************************************\
|
2020-01-01 15:41:43 +01:00
|
|
|
* Copyright (c) 2004-2020
|
2011-04-25 15:25:33 +02:00
|
|
|
*
|
|
|
|
* Author(s):
|
|
|
|
* Volker Fischer
|
|
|
|
*
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU General Public License as published by the Free Software
|
|
|
|
* Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
* version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2013-01-02 21:41:04 +01:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QTextStream>
|
2020-04-23 17:00:58 +02:00
|
|
|
#include <QTranslator>
|
2011-04-25 15:25:33 +02:00
|
|
|
#include "global.h"
|
2013-03-24 11:49:25 +01:00
|
|
|
#include "clientdlg.h"
|
|
|
|
#include "serverdlg.h"
|
2011-04-25 15:25:33 +02:00
|
|
|
#include "settings.h"
|
|
|
|
#include "testbench.h"
|
2019-04-12 18:24:35 +02:00
|
|
|
#include "util.h"
|
2011-04-25 15:25:33 +02:00
|
|
|
|
|
|
|
|
2019-04-03 19:12:45 +02:00
|
|
|
// Implementation **************************************************************
|
|
|
|
|
|
|
|
int main ( int argc, char** argv )
|
|
|
|
{
|
2019-04-12 18:24:35 +02:00
|
|
|
QTextStream& tsConsole = *( ( new ConsoleWriterFactory() )->get() );
|
|
|
|
QString strArgument;
|
|
|
|
double rDbleArgument;
|
2011-04-25 15:25:33 +02:00
|
|
|
|
|
|
|
// initialize all flags and string which might be changed by command line
|
|
|
|
// arguments
|
2020-04-18 18:49:11 +02:00
|
|
|
#if defined( SERVER_BUNDLE ) && ( defined( __APPLE__ ) || defined( __MACOSX ) )
|
|
|
|
// if we are on MacOS and we are building a server bundle, starts Jamulus in server mode
|
2020-04-18 18:49:11 +02:00
|
|
|
bool bIsClient = false;
|
|
|
|
#else
|
2015-01-23 20:43:18 +01:00
|
|
|
bool bIsClient = true;
|
2020-04-18 18:49:11 +02:00
|
|
|
#endif
|
2015-01-23 20:43:18 +01:00
|
|
|
bool bUseGUI = true;
|
|
|
|
bool bStartMinimized = false;
|
|
|
|
bool bShowComplRegConnList = false;
|
2015-10-17 17:37:58 +02:00
|
|
|
bool bDisconnectAllClients = false;
|
2020-04-10 12:28:50 +02:00
|
|
|
bool bUseDoubleSystemFrameSize = true; // default is 128 samples frame size
|
2015-01-23 20:43:18 +01:00
|
|
|
bool bShowAnalyzerConsole = false;
|
|
|
|
bool bCentServPingServerInList = false;
|
2019-09-22 20:13:08 +02:00
|
|
|
bool bNoAutoJackConnect = false;
|
2020-05-04 20:22:22 +02:00
|
|
|
bool bUseTranslation = false;
|
2015-01-23 20:43:18 +01:00
|
|
|
int iNumServerChannels = DEFAULT_USED_NUM_CHANNELS;
|
2020-03-22 18:45:00 +01:00
|
|
|
int iMaxDaysHistory = DEFAULT_DAYS_HISTORY;
|
2019-01-12 13:45:08 +01:00
|
|
|
int iCtrlMIDIChannel = INVALID_MIDI_CH;
|
2015-01-23 20:43:18 +01:00
|
|
|
quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER;
|
|
|
|
ELicenceType eLicenceType = LT_NO_LICENCE;
|
2015-03-25 21:29:52 +01:00
|
|
|
QString strConnOnStartupAddress = "";
|
2015-01-23 20:43:18 +01:00
|
|
|
QString strIniFileName = "";
|
|
|
|
QString strHTMLStatusFileName = "";
|
|
|
|
QString strServerName = "";
|
|
|
|
QString strLoggingFileName = "";
|
|
|
|
QString strHistoryFileName = "";
|
2019-04-03 19:12:45 +02:00
|
|
|
QString strRecordingDirName = "";
|
2015-01-23 20:43:18 +01:00
|
|
|
QString strCentralServer = "";
|
|
|
|
QString strServerInfo = "";
|
|
|
|
QString strWelcomeMessage = "";
|
2020-04-30 20:48:48 +02:00
|
|
|
QString strClientName = APP_NAME;
|
2011-04-25 15:25:33 +02:00
|
|
|
|
|
|
|
// QT docu: argv()[0] is the program name, argv()[1] is the first
|
|
|
|
// argument and argv()[argc()-1] is the last argument.
|
|
|
|
// Start with first argument, therefore "i = 1"
|
|
|
|
for ( int i = 1; i < argc; i++ )
|
|
|
|
{
|
|
|
|
// Server mode flag ----------------------------------------------------
|
|
|
|
if ( GetFlagArgument ( argv,
|
|
|
|
i,
|
|
|
|
"-s",
|
|
|
|
"--server" ) )
|
|
|
|
{
|
|
|
|
bIsClient = false;
|
|
|
|
tsConsole << "- server mode chosen" << endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Use GUI flag --------------------------------------------------------
|
|
|
|
if ( GetFlagArgument ( argv,
|
|
|
|
i,
|
|
|
|
"-n",
|
|
|
|
"--nogui" ) )
|
|
|
|
{
|
|
|
|
bUseGUI = false;
|
|
|
|
tsConsole << "- no GUI mode chosen" << endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-23 20:43:18 +01:00
|
|
|
// Use licence flag ----------------------------------------------------
|
|
|
|
if ( GetFlagArgument ( argv,
|
|
|
|
i,
|
|
|
|
"-L",
|
|
|
|
"--licence" ) )
|
|
|
|
{
|
|
|
|
// right now only the creative commons licence is supported
|
|
|
|
eLicenceType = LT_CREATIVECOMMONS;
|
|
|
|
tsConsole << "- licence required" << endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-10 12:28:50 +02:00
|
|
|
// Use 64 samples frame size mode ----------------------------------------------------
|
|
|
|
if ( GetFlagArgument ( argv,
|
|
|
|
i,
|
|
|
|
"-F",
|
|
|
|
"--fastupdate" ) )
|
|
|
|
{
|
|
|
|
bUseDoubleSystemFrameSize = false; // 64 samples frame size
|
2020-04-15 15:29:43 +02:00
|
|
|
tsConsole << "- using " << SYSTEM_FRAME_SIZE_SAMPLES << " samples frame size mode" << endl;
|
2020-04-10 12:28:50 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-13 20:23:00 +02:00
|
|
|
// Maximum number of channels ------------------------------------------
|
|
|
|
if ( GetNumericArgument ( tsConsole,
|
|
|
|
argc,
|
|
|
|
argv,
|
|
|
|
i,
|
|
|
|
"-u",
|
|
|
|
"--numchannels",
|
|
|
|
1,
|
|
|
|
MAX_NUM_CHANNELS,
|
|
|
|
rDbleArgument ) )
|
|
|
|
{
|
|
|
|
iNumServerChannels = static_cast<int> ( rDbleArgument );
|
|
|
|
|
|
|
|
tsConsole << "- maximum number of channels: "
|
|
|
|
<< iNumServerChannels << endl;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-22 20:24:30 +01:00
|
|
|
// Maximum days in history display -------------------------------------
|
2020-03-21 19:56:53 +01:00
|
|
|
if ( GetNumericArgument ( tsConsole,
|
|
|
|
argc,
|
|
|
|
argv,
|
|
|
|
i,
|
|
|
|
"-D",
|
|
|
|
"--histdays",
|
|
|
|
1,
|
|
|
|
366,
|
|
|
|
rDbleArgument ) )
|
|
|
|
{
|
|
|
|
iMaxDaysHistory = static_cast<int> ( rDbleArgument );
|
|
|
|
|
|
|
|
tsConsole << "- maximum days in history display: "
|
|
|
|
<< iMaxDaysHistory << endl;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-05-13 20:23:00 +02:00
|
|
|
|
2011-05-08 17:01:20 +02:00
|
|
|
// Start minimized -----------------------------------------------------
|
|
|
|
if ( GetFlagArgument ( argv,
|
|
|
|
i,
|
|
|
|
"-z",
|
|
|
|
"--startminimized" ) )
|
|
|
|
{
|
|
|
|
bStartMinimized = true;
|
|
|
|
tsConsole << "- start minimized enabled" << endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-14 18:18:09 +02:00
|
|
|
// Ping servers in list for central server -----------------------------
|
|
|
|
if ( GetFlagArgument ( argv,
|
|
|
|
i,
|
|
|
|
"-g",
|
|
|
|
"--pingservers" ) )
|
|
|
|
{
|
|
|
|
bCentServPingServerInList = true;
|
|
|
|
tsConsole << "- ping servers in slave server list" << endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-22 20:13:08 +02:00
|
|
|
// Disabling auto Jack connections -------------------------------------
|
|
|
|
if ( GetFlagArgument ( argv,
|
|
|
|
i,
|
|
|
|
"-j",
|
|
|
|
"--nojackconnect" ) )
|
|
|
|
{
|
|
|
|
bNoAutoJackConnect = true;
|
|
|
|
tsConsole << "- disable auto Jack connections" << endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-04 20:22:22 +02:00
|
|
|
// Enable translations -------------------------------------------------
|
|
|
|
// Undocumented debugging command line argument: Enable translations
|
|
|
|
// (since translation is still WIP, it is not enabled by default but
|
|
|
|
// must be enabled with this undocumented command line flag)
|
|
|
|
if ( GetFlagArgument ( argv,
|
|
|
|
i,
|
|
|
|
"--translation", // no short form
|
|
|
|
"--translation" ) )
|
|
|
|
{
|
|
|
|
bUseTranslation = true;
|
|
|
|
tsConsole << "- translations enabled" << endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-19 22:24:03 +01:00
|
|
|
// Show all registered servers in the server list ----------------------
|
|
|
|
// Undocumented debugging command line argument: Show all registered
|
|
|
|
// servers in the server list regardless if a ping to the server is
|
2013-02-11 21:24:38 +01:00
|
|
|
// possible or not.
|
2011-11-19 22:24:03 +01:00
|
|
|
if ( GetFlagArgument ( argv,
|
|
|
|
i,
|
|
|
|
"--showallservers", // no short form
|
|
|
|
"--showallservers" ) )
|
|
|
|
{
|
|
|
|
bShowComplRegConnList = true;
|
|
|
|
tsConsole << "- show all registered servers in server list" << endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-17 17:37:58 +02:00
|
|
|
// Disconnect all clients (emergency mode) -----------------------------
|
|
|
|
// Undocumented debugging command line argument: Needed to disconnect
|
|
|
|
// an unwanted client.
|
|
|
|
if ( GetFlagArgument ( argv,
|
|
|
|
i,
|
|
|
|
"--disconnectall", // no short form
|
|
|
|
"--disconnectall" ) )
|
|
|
|
{
|
|
|
|
bDisconnectAllClients = true;
|
|
|
|
tsConsole << "- disconnect all clients" << endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-02 20:52:13 +01:00
|
|
|
// Show analyzer console -----------------------------------------------
|
|
|
|
// Undocumented debugging command line argument: Show the analyzer
|
|
|
|
// console to debug network buffer properties.
|
|
|
|
if ( GetFlagArgument ( argv,
|
|
|
|
i,
|
|
|
|
"--showanalyzerconsole", // no short form
|
|
|
|
"--showanalyzerconsole" ) )
|
|
|
|
{
|
|
|
|
bShowAnalyzerConsole = true;
|
|
|
|
tsConsole << "- show analyzer console" << endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-12 13:45:08 +01:00
|
|
|
// Controller MIDI channel ---------------------------------------------
|
|
|
|
if ( GetNumericArgument ( tsConsole,
|
|
|
|
argc,
|
|
|
|
argv,
|
|
|
|
i,
|
|
|
|
"--ctrlmidich", // no short form
|
|
|
|
"--ctrlmidich",
|
|
|
|
0,
|
|
|
|
15,
|
|
|
|
rDbleArgument ) )
|
|
|
|
{
|
|
|
|
iCtrlMIDIChannel = static_cast<int> ( rDbleArgument );
|
|
|
|
tsConsole << "- selected controller MIDI channel: " << iCtrlMIDIChannel << endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-25 15:25:33 +02:00
|
|
|
// Use logging ---------------------------------------------------------
|
|
|
|
if ( GetStringArgument ( tsConsole,
|
|
|
|
argc,
|
|
|
|
argv,
|
|
|
|
i,
|
|
|
|
"-l",
|
|
|
|
"--log",
|
|
|
|
strArgument ) )
|
|
|
|
{
|
|
|
|
strLoggingFileName = strArgument;
|
|
|
|
tsConsole << "- logging file name: " << strLoggingFileName << endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Port number ---------------------------------------------------------
|
|
|
|
if ( GetNumericArgument ( tsConsole,
|
|
|
|
argc,
|
|
|
|
argv,
|
|
|
|
i,
|
|
|
|
"-p",
|
|
|
|
"--port",
|
|
|
|
0,
|
|
|
|
65535,
|
|
|
|
rDbleArgument ) )
|
|
|
|
{
|
|
|
|
iPortNumber = static_cast<quint16> ( rDbleArgument );
|
|
|
|
tsConsole << "- selected port number: " << iPortNumber << endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// HTML status file ----------------------------------------------------
|
|
|
|
if ( GetStringArgument ( tsConsole,
|
|
|
|
argc,
|
|
|
|
argv,
|
|
|
|
i,
|
|
|
|
"-m",
|
|
|
|
"--htmlstatus",
|
|
|
|
strArgument ) )
|
|
|
|
{
|
|
|
|
strHTMLStatusFileName = strArgument;
|
|
|
|
tsConsole << "- HTML status file name: " << strHTMLStatusFileName << endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( GetStringArgument ( tsConsole,
|
|
|
|
argc,
|
|
|
|
argv,
|
|
|
|
i,
|
|
|
|
"-a",
|
|
|
|
"--servername",
|
|
|
|
strArgument ) )
|
|
|
|
{
|
|
|
|
strServerName = strArgument;
|
|
|
|
tsConsole << "- server name for HTML status file: " << strServerName << endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-30 22:03:01 +02:00
|
|
|
// Client Name ---------------------------------------------------------
|
|
|
|
if ( GetStringArgument ( tsConsole,
|
|
|
|
argc,
|
|
|
|
argv,
|
|
|
|
i,
|
|
|
|
"--clientname",
|
|
|
|
"--clientname",
|
|
|
|
strArgument ) )
|
|
|
|
{
|
|
|
|
strClientName = QString ( APP_NAME ) + " " + strArgument;
|
|
|
|
tsConsole << "- client name: " << strClientName << endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Server history file name --------------------------------------------
|
2011-04-25 15:25:33 +02:00
|
|
|
if ( GetStringArgument ( tsConsole,
|
|
|
|
argc,
|
|
|
|
argv,
|
|
|
|
i,
|
|
|
|
"-y",
|
|
|
|
"--history",
|
|
|
|
strArgument ) )
|
|
|
|
{
|
|
|
|
strHistoryFileName = strArgument;
|
|
|
|
tsConsole << "- history file name: " << strHistoryFileName << endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-03 19:12:45 +02:00
|
|
|
// Recording directory -------------------------------------------------
|
|
|
|
if ( GetStringArgument ( tsConsole,
|
|
|
|
argc,
|
|
|
|
argv,
|
|
|
|
i,
|
|
|
|
"-R",
|
2020-03-28 18:51:25 +01:00
|
|
|
"--recording",
|
2019-04-03 19:12:45 +02:00
|
|
|
strArgument ) )
|
|
|
|
{
|
|
|
|
strRecordingDirName = strArgument;
|
|
|
|
tsConsole << "- recording directory name: " << strRecordingDirName << endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-25 15:25:33 +02:00
|
|
|
// Central server ------------------------------------------------------
|
|
|
|
if ( GetStringArgument ( tsConsole,
|
|
|
|
argc,
|
|
|
|
argv,
|
|
|
|
i,
|
|
|
|
"-e",
|
|
|
|
"--centralserver",
|
|
|
|
strArgument ) )
|
|
|
|
{
|
|
|
|
strCentralServer = strArgument;
|
|
|
|
tsConsole << "- central server: " << strCentralServer << endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Server info ---------------------------------------------------------
|
|
|
|
if ( GetStringArgument ( tsConsole,
|
|
|
|
argc,
|
|
|
|
argv,
|
|
|
|
i,
|
|
|
|
"-o",
|
|
|
|
"--serverinfo",
|
|
|
|
strArgument ) )
|
|
|
|
{
|
|
|
|
strServerInfo = strArgument;
|
|
|
|
tsConsole << "- server info: " << strServerInfo << endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-11 21:24:38 +01:00
|
|
|
// Server welcome message ----------------------------------------------
|
|
|
|
if ( GetStringArgument ( tsConsole,
|
|
|
|
argc,
|
|
|
|
argv,
|
|
|
|
i,
|
|
|
|
"-w",
|
|
|
|
"--welcomemessage",
|
|
|
|
strArgument ) )
|
|
|
|
{
|
|
|
|
strWelcomeMessage = strArgument;
|
|
|
|
tsConsole << "- welcome message: " << strWelcomeMessage << endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-25 15:25:33 +02:00
|
|
|
// Initialization file -------------------------------------------------
|
|
|
|
if ( GetStringArgument ( tsConsole,
|
|
|
|
argc,
|
|
|
|
argv,
|
|
|
|
i,
|
|
|
|
"-i",
|
|
|
|
"--inifile",
|
|
|
|
strArgument ) )
|
|
|
|
{
|
|
|
|
strIniFileName = strArgument;
|
|
|
|
tsConsole << "- initialization file name: " << strIniFileName << endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Connect on startup --------------------------------------------------
|
2015-03-25 21:29:52 +01:00
|
|
|
if ( GetStringArgument ( tsConsole,
|
|
|
|
argc,
|
|
|
|
argv,
|
|
|
|
i,
|
|
|
|
"-c",
|
|
|
|
"--connect",
|
|
|
|
strArgument ) )
|
2011-04-25 15:25:33 +02:00
|
|
|
{
|
2015-03-25 21:29:52 +01:00
|
|
|
strConnOnStartupAddress = strArgument;
|
|
|
|
tsConsole << "- connect on startup to address: " << strConnOnStartupAddress << endl;
|
2011-04-25 15:25:33 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-20 20:27:07 +02:00
|
|
|
// Version number ------------------------------------------------------
|
|
|
|
if ( ( !strcmp ( argv[i], "--version" ) ) ||
|
|
|
|
( !strcmp ( argv[i], "-v" ) ) )
|
|
|
|
{
|
|
|
|
tsConsole << CAboutDlg::GetVersionAndNameStr ( false ) << endl;
|
|
|
|
exit ( 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-25 15:25:33 +02:00
|
|
|
// Help (usage) flag ---------------------------------------------------
|
|
|
|
if ( ( !strcmp ( argv[i], "--help" ) ) ||
|
|
|
|
( !strcmp ( argv[i], "-h" ) ) ||
|
|
|
|
( !strcmp ( argv[i], "-?" ) ) )
|
|
|
|
{
|
|
|
|
const QString strHelp = UsageArguments ( argv );
|
|
|
|
tsConsole << strHelp << endl;
|
|
|
|
exit ( 1 );
|
|
|
|
}
|
|
|
|
|
2020-04-20 20:27:07 +02:00
|
|
|
|
2011-04-25 15:25:33 +02:00
|
|
|
// Unknown option ------------------------------------------------------
|
|
|
|
tsConsole << argv[0] << ": ";
|
|
|
|
tsConsole << "Unknown option '" <<
|
|
|
|
argv[i] << "' -- use '--help' for help" << endl;
|
|
|
|
|
|
|
|
// clicking on the Mac application bundle, the actual application
|
|
|
|
// is called with weird command line args -> do not exit on these
|
|
|
|
#if !( defined ( __APPLE__ ) || defined ( __MACOSX ) )
|
|
|
|
exit ( 1 );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-04-23 17:00:58 +02:00
|
|
|
|
2011-04-25 15:25:33 +02:00
|
|
|
// Dependencies ------------------------------------------------------------
|
|
|
|
// per definition: if we are in "GUI" server mode and no central server
|
|
|
|
// address is given, we use the default central server address
|
|
|
|
if ( !bIsClient && bUseGUI && strCentralServer.isEmpty() )
|
|
|
|
{
|
|
|
|
strCentralServer = DEFAULT_SERVER_ADDRESS;
|
|
|
|
}
|
|
|
|
|
2020-04-30 22:03:01 +02:00
|
|
|
|
2011-04-25 15:25:33 +02:00
|
|
|
// Application/GUI setup ---------------------------------------------------
|
|
|
|
// Application object
|
2019-04-12 18:12:22 +02:00
|
|
|
if ( !bUseGUI && !strHistoryFileName.isEmpty() )
|
2019-04-03 19:12:45 +02:00
|
|
|
{
|
2019-05-19 09:30:49 +02:00
|
|
|
tsConsole << "Qt5 requires a windowing system to paint a JPEG image; image will use SVG" << endl;
|
2019-04-03 19:12:45 +02:00
|
|
|
}
|
2019-04-12 18:12:22 +02:00
|
|
|
QCoreApplication* pApp = bUseGUI
|
2019-04-03 19:12:45 +02:00
|
|
|
? new QApplication ( argc, argv )
|
|
|
|
: new QCoreApplication ( argc, argv );
|
2011-04-25 15:25:33 +02:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
2013-06-03 18:07:17 +02:00
|
|
|
// set application priority class -> high priority
|
2011-04-25 15:25:33 +02:00
|
|
|
SetPriorityClass ( GetCurrentProcess(), HIGH_PRIORITY_CLASS );
|
|
|
|
|
|
|
|
// For accessible support we need to add a plugin to qt. The plugin has to
|
2013-03-24 11:49:25 +01:00
|
|
|
// be located in the install directory of the software by the installer.
|
|
|
|
// Here, we set the path to our application path.
|
2011-04-25 15:25:33 +02:00
|
|
|
QDir ApplDir ( QApplication::applicationDirPath() );
|
2019-04-12 18:12:22 +02:00
|
|
|
pApp->addLibraryPath ( QString ( ApplDir.absolutePath() ) );
|
2011-04-25 15:25:33 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// init resources
|
|
|
|
Q_INIT_RESOURCE(resources);
|
|
|
|
|
2020-05-04 20:22:22 +02:00
|
|
|
// load translations
|
|
|
|
QTranslator myappTranslator;
|
2011-04-25 15:25:33 +02:00
|
|
|
|
2020-05-04 20:22:22 +02:00
|
|
|
if ( bUseGUI && bUseTranslation )
|
|
|
|
{
|
|
|
|
if ( myappTranslator.load ( ":/translations/translation.qm" ) )
|
|
|
|
{
|
|
|
|
pApp->installTranslator ( &myappTranslator );
|
|
|
|
}
|
|
|
|
}
|
2020-04-23 17:00:58 +02:00
|
|
|
|
|
|
|
|
2011-04-25 15:25:33 +02:00
|
|
|
// TEST -> activate the following line to activate the test bench,
|
|
|
|
//CTestbench Testbench ( "127.0.0.1", LLCON_DEFAULT_PORT_NUMBER );
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2019-04-12 18:02:26 +02:00
|
|
|
if ( bIsClient )
|
2011-04-25 15:25:33 +02:00
|
|
|
{
|
|
|
|
// Client:
|
|
|
|
// actual client object
|
2015-03-25 21:29:52 +01:00
|
|
|
CClient Client ( iPortNumber,
|
2019-01-12 13:45:08 +01:00
|
|
|
strConnOnStartupAddress,
|
2019-09-22 20:13:08 +02:00
|
|
|
iCtrlMIDIChannel,
|
2020-04-30 20:48:48 +02:00
|
|
|
bNoAutoJackConnect,
|
|
|
|
strClientName );
|
2011-04-25 15:25:33 +02:00
|
|
|
|
|
|
|
// load settings from init-file
|
2011-05-21 18:53:01 +02:00
|
|
|
CSettings Settings ( &Client, strIniFileName );
|
|
|
|
Settings.Load();
|
2011-04-25 15:25:33 +02:00
|
|
|
|
2015-03-25 21:29:52 +01:00
|
|
|
if ( bUseGUI )
|
|
|
|
{
|
|
|
|
// GUI object
|
|
|
|
CClientDlg ClientDlg ( &Client,
|
|
|
|
&Settings,
|
|
|
|
strConnOnStartupAddress,
|
|
|
|
bShowComplRegConnList,
|
|
|
|
bShowAnalyzerConsole,
|
2019-04-12 18:04:28 +02:00
|
|
|
nullptr,
|
2015-03-25 21:29:52 +01:00
|
|
|
Qt::Window );
|
|
|
|
|
|
|
|
// show dialog
|
|
|
|
ClientDlg.show();
|
2019-04-12 18:12:22 +02:00
|
|
|
pApp->exec();
|
2015-03-25 21:29:52 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// only start application without using the GUI
|
|
|
|
tsConsole << CAboutDlg::GetVersionAndNameStr ( false ) << endl;
|
|
|
|
|
2019-04-12 18:12:22 +02:00
|
|
|
pApp->exec();
|
2015-03-25 21:29:52 +01:00
|
|
|
}
|
2011-04-25 15:25:33 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Server:
|
|
|
|
// actual server object
|
2011-05-13 20:23:00 +02:00
|
|
|
CServer Server ( iNumServerChannels,
|
2020-03-21 19:56:53 +01:00
|
|
|
iMaxDaysHistory,
|
2011-05-13 20:23:00 +02:00
|
|
|
strLoggingFileName,
|
2011-04-25 15:25:33 +02:00
|
|
|
iPortNumber,
|
|
|
|
strHTMLStatusFileName,
|
|
|
|
strHistoryFileName,
|
|
|
|
strServerName,
|
|
|
|
strCentralServer,
|
2012-07-14 18:18:09 +02:00
|
|
|
strServerInfo,
|
2013-02-11 21:24:38 +01:00
|
|
|
strWelcomeMessage,
|
2019-04-03 19:12:45 +02:00
|
|
|
strRecordingDirName,
|
2015-01-23 20:43:18 +01:00
|
|
|
bCentServPingServerInList,
|
2015-10-17 17:37:58 +02:00
|
|
|
bDisconnectAllClients,
|
2020-04-04 19:03:19 +02:00
|
|
|
bUseDoubleSystemFrameSize,
|
2015-01-23 20:43:18 +01:00
|
|
|
eLicenceType );
|
2011-04-25 15:25:33 +02:00
|
|
|
if ( bUseGUI )
|
|
|
|
{
|
2011-04-25 18:16:31 +02:00
|
|
|
// load settings from init-file
|
2011-05-21 18:53:01 +02:00
|
|
|
CSettings Settings ( &Server, strIniFileName );
|
|
|
|
Settings.Load();
|
2011-04-25 18:16:31 +02:00
|
|
|
|
2011-04-30 15:01:26 +02:00
|
|
|
// update server list AFTER restoring the settings from the
|
|
|
|
// settings file
|
|
|
|
Server.UpdateServerList();
|
|
|
|
|
2011-04-25 15:25:33 +02:00
|
|
|
// GUI object for the server
|
2013-03-24 16:42:23 +01:00
|
|
|
CServerDlg ServerDlg ( &Server,
|
|
|
|
&Settings,
|
|
|
|
bStartMinimized,
|
2019-04-12 18:04:28 +02:00
|
|
|
nullptr,
|
2013-03-24 16:42:23 +01:00
|
|
|
Qt::Window );
|
2011-04-25 15:25:33 +02:00
|
|
|
|
2011-05-25 22:00:54 +02:00
|
|
|
// show dialog (if not the minimized flag is set)
|
|
|
|
if ( !bStartMinimized )
|
|
|
|
{
|
|
|
|
ServerDlg.show();
|
|
|
|
}
|
|
|
|
|
2019-04-12 18:12:22 +02:00
|
|
|
pApp->exec();
|
2011-04-25 15:25:33 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// only start application without using the GUI
|
|
|
|
tsConsole << CAboutDlg::GetVersionAndNameStr ( false ) << endl;
|
|
|
|
|
2020-04-19 20:29:44 +02:00
|
|
|
// update serverlist
|
|
|
|
Server.UpdateServerList();
|
|
|
|
|
2019-04-12 18:12:22 +02:00
|
|
|
pApp->exec();
|
2011-04-25 15:25:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
catch ( CGenErr generr )
|
|
|
|
{
|
|
|
|
// show generic error
|
|
|
|
if ( bUseGUI )
|
|
|
|
{
|
2019-04-12 18:04:28 +02:00
|
|
|
QMessageBox::critical ( nullptr,
|
2011-04-25 15:25:33 +02:00
|
|
|
APP_NAME,
|
|
|
|
generr.GetErrorText(),
|
|
|
|
"Quit",
|
2019-04-12 18:04:28 +02:00
|
|
|
nullptr );
|
2011-04-25 15:25:33 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tsConsole << generr.GetErrorText() << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************\
|
|
|
|
* Command Line Argument Parsing *
|
|
|
|
\******************************************************************************/
|
|
|
|
QString UsageArguments ( char **argv )
|
|
|
|
{
|
|
|
|
return
|
2020-05-03 20:34:01 +02:00
|
|
|
"Usage: " + QString ( argv[0] ) + " [option] [optional argument]\n"
|
2011-04-25 15:25:33 +02:00
|
|
|
"\nRecognized options:\n"
|
2020-04-20 20:27:07 +02:00
|
|
|
" -h, -?, --help display this help text and exit\n"
|
2020-04-05 08:13:53 +02:00
|
|
|
" -i, --inifile initialization file name\n"
|
2020-05-03 20:34:01 +02:00
|
|
|
" -n, --nogui disable GUI\n"
|
|
|
|
" -p, --port set your local port number\n"
|
|
|
|
" -v, --version output version information and exit\n"
|
|
|
|
"\nServer only:\n"
|
|
|
|
" -a, --servername server name, required for HTML status\n"
|
|
|
|
" -D, --histdays number of days of history to display\n"
|
|
|
|
" -e, --centralserver address of the central server\n"
|
|
|
|
" -F, --fastupdate use 64 samples frame size mode\n"
|
|
|
|
" -g, --pingservers ping servers in list to keep NAT port open\n"
|
|
|
|
" (central server only)\n"
|
2012-07-14 18:18:09 +02:00
|
|
|
" -l, --log enable logging, set file name\n"
|
2015-01-23 20:43:18 +01:00
|
|
|
" -L, --licence a licence must be accepted on a new\n"
|
2020-05-03 20:34:01 +02:00
|
|
|
" connection\n"
|
|
|
|
" -m, --htmlstatus enable HTML status file, set file name\n"
|
2011-05-03 22:37:06 +02:00
|
|
|
" -o, --serverinfo infos of the server(s) in the format:\n"
|
|
|
|
" [name];[city];[country as QLocale ID]; ...\n"
|
|
|
|
" [server1 address];[server1 name]; ...\n"
|
|
|
|
" [server1 city]; ...\n"
|
|
|
|
" [server1 country as QLocale ID]; ...\n"
|
2020-05-03 20:34:01 +02:00
|
|
|
" [server2 address]; ...\n"
|
2019-04-11 22:25:36 +02:00
|
|
|
" -R, --recording enables recording and sets directory to contain\n"
|
2020-05-03 20:34:01 +02:00
|
|
|
" recorded jams\n"
|
2012-07-14 18:18:09 +02:00
|
|
|
" -s, --server start server\n"
|
2020-05-03 20:34:01 +02:00
|
|
|
" -u, --numchannels maximum number of channels\n"
|
|
|
|
" -w, --welcomemessage welcome message on connect\n"
|
|
|
|
" -y, --history enable connection history and set file name\n"
|
|
|
|
" -z, --startminimized start minimizied\n"
|
|
|
|
"\nClient only:\n"
|
|
|
|
" -c, --connect connect to given server address on startup\n"
|
|
|
|
" -j, --nojackconnect disable auto Jack connections\n"
|
|
|
|
" --ctrlmidich MIDI controller channel to listen\n"
|
2020-04-30 22:03:01 +02:00
|
|
|
" --clientname client name (window title and jack client name)\n"
|
2020-05-03 20:34:01 +02:00
|
|
|
"\nExample: " + QString ( argv[0] ) + " -s -inifile myinifile.ini\n";
|
2011-04-25 15:25:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool GetFlagArgument ( char** argv,
|
|
|
|
int& i,
|
|
|
|
QString strShortOpt,
|
|
|
|
QString strLongOpt )
|
|
|
|
{
|
|
|
|
if ( ( !strShortOpt.compare ( argv[i] ) ) ||
|
|
|
|
( !strLongOpt.compare ( argv[i] ) ) )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GetStringArgument ( QTextStream& tsConsole,
|
|
|
|
int argc,
|
|
|
|
char** argv,
|
|
|
|
int& i,
|
|
|
|
QString strShortOpt,
|
|
|
|
QString strLongOpt,
|
|
|
|
QString& strArg )
|
|
|
|
{
|
|
|
|
if ( ( !strShortOpt.compare ( argv[i] ) ) ||
|
|
|
|
( !strLongOpt.compare ( argv[i] ) ) )
|
|
|
|
{
|
|
|
|
if ( ++i >= argc )
|
|
|
|
{
|
|
|
|
tsConsole << argv[0] << ": ";
|
|
|
|
tsConsole << "'" << strLongOpt << "' needs a string argument" << endl;
|
|
|
|
exit ( 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
strArg = argv[i];
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GetNumericArgument ( QTextStream& tsConsole,
|
|
|
|
int argc,
|
|
|
|
char** argv,
|
|
|
|
int& i,
|
|
|
|
QString strShortOpt,
|
|
|
|
QString strLongOpt,
|
|
|
|
double rRangeStart,
|
|
|
|
double rRangeStop,
|
|
|
|
double& rValue )
|
|
|
|
{
|
|
|
|
if ( ( !strShortOpt.compare ( argv[i] ) ) ||
|
|
|
|
( !strLongOpt.compare ( argv[i] ) ) )
|
|
|
|
{
|
|
|
|
if ( ++i >= argc )
|
|
|
|
{
|
|
|
|
tsConsole << argv[0] << ": ";
|
|
|
|
|
|
|
|
tsConsole << "'" <<
|
|
|
|
strLongOpt << "' needs a numeric argument between " <<
|
|
|
|
rRangeStart << " and " << rRangeStop << endl;
|
|
|
|
|
|
|
|
exit ( 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
char *p;
|
|
|
|
rValue = strtod ( argv[i], &p );
|
|
|
|
if ( *p ||
|
|
|
|
( rValue < rRangeStart ) ||
|
|
|
|
( rValue > rRangeStop ) )
|
|
|
|
{
|
|
|
|
tsConsole << argv[0] << ": ";
|
|
|
|
|
|
|
|
tsConsole << "'" <<
|
|
|
|
strLongOpt << "' needs a numeric argument between " <<
|
|
|
|
rRangeStart << " and " << rRangeStop << endl;
|
|
|
|
|
|
|
|
exit ( 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|