MCPcopy Create free account
hub / github.com/YACReader/yacreader / setPort

Function setPort

YACReaderLibraryServer/main.cpp:380–405  ·  view source on GitHub ↗

----------------------------------------------------------------------------- set-port--------------------------------------------------------------------- -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

378// set-port---------------------------------------------------------------------
379// -----------------------------------------------------------------------------
380int setPort(QCoreApplication &app, QCommandLineParser &parser, QTextStream &qout)
381{
382 parser.clearPositionalArguments();
383 parser.addPositionalArgument("set-port", "Set server port (persistent).");
384 parser.addPositionalArgument("port", "1-65535", "<port>");
385 parser.process(app);
386
387 const QStringList args = parser.positionalArguments();
388 if (args.length() != 2) {
389 parser.showHelp(1);
390 return 1;
391 }
392
393 bool valid;
394 qint32 port = args.at(1).toInt(&valid);
395 if (!valid || port < 1 || port > 65535) {
396 qout << "Invalid server port";
397 parser.showHelp(1);
398 return 1;
399 }
400
401 QSettings *settings = new QSettings(YACReader::getSettingsPath() + "/" + QCoreApplication::applicationName() + ".ini", QSettings::IniFormat);
402 settings->setValue("listener/port", QString::number(port));
403 delete settings;
404 return 0;
405}
406
407// -----------------------------------------------------------------------------
408// rescan-xml-info--------------------------------------------------------------

Callers 1

mainFunction · 0.85

Calls 2

setValueMethod · 0.80
processMethod · 0.45

Tested by

no test coverage detected