Ref T192, parser finds illegal cmd argument combinations

This commit is contained in:
Klaus Basan
2017-11-18 18:53:43 +01:00
parent 9f889bfce7
commit c3f3a30b35

View File

@@ -31,12 +31,40 @@ CSwiftGuiStdApplication::CSwiftGuiStdApplication() :
CStatusMessageList CSwiftGuiStdApplication::startHookIn() CStatusMessageList CSwiftGuiStdApplication::startHookIn()
{ {
Q_ASSERT_X(m_parsed, Q_FUNC_INFO, "Not yet parsed cmd line arguments"); Q_ASSERT_X(m_parsed, Q_FUNC_INFO, "Not yet parsed cmd line arguments");
CoreModes::CoreMode coreMode = CoreModes::CoreInGuiProcess;
const QString dBusAddress(this->getCmdDBusAddressValue()); QString dBusAddress(this->getCmdDBusAddressValue());
if (this->isParserOptionSet(m_cmdFacadeMode)) const QString coreModeStr = this->isParserOptionSet(m_cmdFacadeMode) ? this->getParserValue(m_cmdFacadeMode) : QStringLiteral("");
CoreModes::CoreMode coreMode = CoreModes::stringToCoreMode(coreModeStr);
// Valid combination?
if (!coreModeStr.isEmpty())
{ {
const QString v(this->getParserValue(m_cmdFacadeMode)); if (coreMode == CoreModes::CoreInGuiProcess && !dBusAddress.isEmpty())
coreMode = CoreModes::stringToCoreMode(v); {
const CStatusMessage m = CStatusMessage(this, CLogCategory::validation()).
error("Inconsistent pair DBus: '%1' and core: '%2'")
<< dBusAddress << coreModeStr;
return CStatusMessageList(m) ;
}
}
// Implicit configuration
CStatusMessageList msgs;
if (!dBusAddress.isEmpty() && coreModeStr.isEmpty())
{
coreMode = CoreModes::CoreExternalAudioGui; // default
const CStatusMessage m = CStatusMessage(this, CLogCategory::validation()).
info("No DBus address, setting core mode: '%1'")
<< CoreModes::coreModeToString(coreMode);
msgs.push_back(m);
}
else if (dBusAddress.isEmpty() && (coreMode == CoreModes::CoreExternalCoreAudio || coreMode == CoreModes::CoreExternalAudioGui))
{
dBusAddress = CDBusServer::sessionBusAddress(); // a possible default
const CStatusMessage m = CStatusMessage(this, CLogCategory::validation()).
info("Setting DBus address to '%1'")
<< dBusAddress;
msgs.push_back(m);
} }
CCoreFacadeConfig runtimeConfig; CCoreFacadeConfig runtimeConfig;
@@ -45,15 +73,18 @@ CStatusMessageList CSwiftGuiStdApplication::startHookIn()
case CoreModes::CoreExternalCoreAudio: case CoreModes::CoreExternalCoreAudio:
runtimeConfig = CCoreFacadeConfig::remote(dBusAddress); runtimeConfig = CCoreFacadeConfig::remote(dBusAddress);
break; break;
case CoreModes::CoreExternalAudioGui:
runtimeConfig = CCoreFacadeConfig::remoteLocalAudio(dBusAddress);
break;
default: default:
case CoreModes::CoreInGuiProcess: case CoreModes::CoreInGuiProcess:
runtimeConfig = CCoreFacadeConfig::local(dBusAddress); runtimeConfig = CCoreFacadeConfig::local(dBusAddress);
break; break;
case CoreModes::CoreExternalAudioGui:
runtimeConfig = CCoreFacadeConfig::remoteLocalAudio(dBusAddress);
break;
} }
return this->useContexts(runtimeConfig);
const CStatusMessageList contextMsgs = this->useContexts(runtimeConfig);
msgs.push_back(contextMsgs);
return contextMsgs;
} }
bool CSwiftGuiStdApplication::parsingHookIn() bool CSwiftGuiStdApplication::parsingHookIn()