Skip to content

Commit

Permalink
Merge pull request #3191 from pljones/patch/minor-refactoring-of-main…
Browse files Browse the repository at this point in the history
…_cpp

Minor refactoring of main cpp
  • Loading branch information
pljones authored Nov 2, 2023
2 parents 87c3d92 + 582eee0 commit 1265a7f
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,7 @@ int main ( int argc, char** argv )
if ( GetNumericArgument ( argc, argv, i, "-u", "--numchannels", 1, MAX_NUM_CHANNELS, rDbleArgument ) )
{
iNumServerChannels = static_cast<int> ( rDbleArgument );

qInfo() << qUtf8Printable ( QString ( "- maximum number of channels: %1" ).arg ( iNumServerChannels ) );

CommandLineOptions << "--numchannels";
ServerOnlyOptions << "--numchannels";
continue;
Expand Down Expand Up @@ -599,20 +597,19 @@ int main ( int argc, char** argv )
bUseGUI = false;
qWarning() << "No GUI support compiled. Running in headless mode.";
}
#endif

if ( bIsClient )
#endif
#ifdef SERVER_ONLY
if ( bIsClient )
{
qCritical() << "Only --server mode is supported in this build.";
exit ( 1 );
}
#else

// TODO create settings in default state, if loading from file do that next, then come back here to
// override from command line options, then create client or server, letting them do the validation

#else
if ( bIsClient )
{

if ( ServerOnlyOptions.size() != 0 )
{
qCritical() << qUtf8Printable ( QString ( "%1: Server only option(s) '%2' used. Did you omit '--server'?" )
Expand All @@ -639,6 +636,7 @@ int main ( int argc, char** argv )
else
#endif
{

if ( ClientOnlyOptions.size() != 0 )
{
qCritical() << qUtf8Printable (
Expand Down Expand Up @@ -786,12 +784,10 @@ int main ( int argc, char** argv )
strServerBindIP = "";
}
}

#ifndef NO_JSON_RPC
//

// strJsonRpcBind address defaults to loopback and should not be empty, but
// in the odd chance that an empty IP is passed, we'll check for it here.

if ( strJsonRpcBindIP.trimmed().isEmpty() )
{
qCritical() << qUtf8Printable ( QString ( "JSON-RPC is enabled but the bind address provided is empty, exiting." ) );
Expand All @@ -809,7 +805,6 @@ int main ( int argc, char** argv )
exit ( 1 );
}
}

#endif
}

Expand Down Expand Up @@ -937,13 +932,6 @@ int main ( int argc, char** argv )
CClientSettings Settings ( &Client, strIniFileName );
Settings.Load ( CommandLineOptions );

// load translation
if ( bUseGUI && bUseTranslation )
{
CLocale::LoadTranslation ( Settings.strLanguage, pApp );
CInstPictures::UpdateTableOnLanguageChange();
}

# ifndef NO_JSON_RPC
if ( pRpcServer )
{
Expand All @@ -954,6 +942,13 @@ int main ( int argc, char** argv )
# ifndef HEADLESS
if ( bUseGUI )
{
// load translation
if ( bUseTranslation )
{
CLocale::LoadTranslation ( Settings.strLanguage, pApp );
CInstPictures::UpdateTableOnLanguageChange();
}

// GUI object
CClientDlg ClientDlg ( &Client,
&Settings,
Expand All @@ -967,6 +962,7 @@ int main ( int argc, char** argv )

// show dialog
ClientDlg.show();

pApp->exec();
}
else
Expand Down Expand Up @@ -1009,8 +1005,8 @@ int main ( int argc, char** argv )
{
new CServerRpc ( &Server, pRpcServer, pRpcServer );
}
#endif

#endif
#ifndef HEADLESS
if ( bUseGUI )
{
Expand All @@ -1019,7 +1015,7 @@ int main ( int argc, char** argv )
Settings.Load ( CommandLineOptions );

// load translation
if ( bUseGUI && bUseTranslation )
if ( bUseTranslation )
{
CLocale::LoadTranslation ( Settings.strLanguage, pApp );
}
Expand Down

0 comments on commit 1265a7f

Please sign in to comment.