Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor refactoring of main cpp #3191

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 )
ann0see marked this conversation as resolved.
Show resolved Hide resolved
{
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 )
ann0see marked this conversation as resolved.
Show resolved Hide resolved
{
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 )
pljones marked this conversation as resolved.
Show resolved Hide resolved
{
CLocale::LoadTranslation ( Settings.strLanguage, pApp );
}
Expand Down