diff --git a/src/blackcore/context/contextsimulator.h b/src/blackcore/context/contextsimulator.h index 631411706..6a822b7d8 100644 --- a/src/blackcore/context/contextsimulator.h +++ b/src/blackcore/context/contextsimulator.h @@ -200,6 +200,9 @@ namespace BlackCore //! Request weather grid. Argument identifier is past in the signal to identify the requestor virtual void requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier) = 0; + //! Parse a given command line + virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) = 0; + protected: //! Constructor IContextSimulator(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) : CContext(mode, runtime) {} diff --git a/src/blackcore/context/contextsimulatorempty.h b/src/blackcore/context/contextsimulatorempty.h index cf7d514e4..faa28763d 100644 --- a/src/blackcore/context/contextsimulatorempty.h +++ b/src/blackcore/context/contextsimulatorempty.h @@ -214,6 +214,15 @@ namespace BlackCore logEmptyContextWarning(Q_FUNC_INFO); return false; } + + //! \copydoc IContextSimulator::parseCommandLine + virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) + { + Q_UNUSED(commandLine); + Q_UNUSED(originator); + logEmptyContextWarning(Q_FUNC_INFO); + return false; + } }; } // namespace } // namespace diff --git a/src/blackcore/context/contextsimulatorimpl.cpp b/src/blackcore/context/contextsimulatorimpl.cpp index 35b8f9583..64299c3a2 100644 --- a/src/blackcore/context/contextsimulatorimpl.cpp +++ b/src/blackcore/context/contextsimulatorimpl.cpp @@ -22,6 +22,7 @@ #include "blackmisc/aviation/callsign.h" #include "blackmisc/compare.h" #include "blackmisc/dbusserver.h" +#include "blackmisc/simplecommandparser.h" #include "blackmisc/logcategory.h" #include "blackmisc/loghandler.h" #include "blackmisc/logmessage.h" @@ -581,6 +582,26 @@ namespace BlackCore emit CContext::changedLogOrDebugSettings(); } + bool CContextSimulator::parseCommandLine(const QString &commandLine, const CIdentifier &originator) + { + Q_UNUSED(originator); + if (commandLine.isEmpty()) { return false; } + CSimpleCommandParser parser( + { + ".plugin", + ".drv", ".driver" // forwarded to driver + }); + parser.parse(commandLine); + if (!parser.isKnownCommand()) { return false; } + + if (parser.matchesCommand("plugin") || parser.matchesCommand("drv") || parser.matchesCommand("driver")) + { + if (!this->m_simulatorPlugin.second) { return false; } + return this->m_simulatorPlugin.second->parseCommandLine(commandLine, originator); + } + return false; + } + void CContextSimulator::highlightAircraft(const CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const CTime &displayTime) { if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << aircraftToHighlight << enableHighlight << displayTime; } diff --git a/src/blackcore/context/contextsimulatorimpl.h b/src/blackcore/context/contextsimulatorimpl.h index f66a16c34..86c88d799 100644 --- a/src/blackcore/context/contextsimulatorimpl.h +++ b/src/blackcore/context/contextsimulatorimpl.h @@ -73,7 +73,8 @@ namespace BlackCore void gracefulShutdown(); public slots: - //! \name Interface implementations + // ----------------------------- context interface ----------------------------- + //! \publicsection //! @{ virtual BlackMisc::Simulation::CSimulatorPluginInfo getSimulatorPluginInfo() const override; virtual BlackMisc::Simulation::CSimulatorPluginInfoList getAvailableSimulatorPlugins() const override; @@ -102,6 +103,17 @@ namespace BlackCore virtual void enableMatchingMessages(bool enabled) override; //! @} + //! \ingroup commandline + //! @{ + //!
+            //! .plugin        forwared to plugin, see details there
+            //! .driver .drv   forwared to plugin (same as above)
+            //! 
+ //! @} + //! \copydoc IContextSimulator::parseCommandLine + virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override; + // ----------------------------- context interface ----------------------------- + protected: //! Constructor CContextSimulator(CCoreFacadeConfig::ContextMode, CCoreFacade *runtime); diff --git a/src/blackcore/context/contextsimulatorproxy.cpp b/src/blackcore/context/contextsimulatorproxy.cpp index ecc01085e..ca2a99be3 100644 --- a/src/blackcore/context/contextsimulatorproxy.cpp +++ b/src/blackcore/context/contextsimulatorproxy.cpp @@ -193,5 +193,10 @@ namespace BlackCore { m_dBusInterface->callDBus(QLatin1Literal("enableMatchingMessages"), enabled); } + + bool CContextSimulatorProxy::parseCommandLine(const QString &commandLine, const CIdentifier &originator) + { + return m_dBusInterface->callDBusRet(QLatin1Literal("parseCommandLine"), commandLine, originator); + } } // namespace } // namespace diff --git a/src/blackcore/context/contextsimulatorproxy.h b/src/blackcore/context/contextsimulatorproxy.h index 965595f02..f706757df 100644 --- a/src/blackcore/context/contextsimulatorproxy.h +++ b/src/blackcore/context/contextsimulatorproxy.h @@ -78,6 +78,7 @@ namespace BlackCore virtual BlackMisc::CStatusMessageList getMatchingMessages(const BlackMisc::Aviation::CCallsign &callsign) const override; virtual bool isMatchingMessagesEnabled() const override; virtual void enableMatchingMessages(bool enabled) override; + virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override; //! @} private: diff --git a/src/blackcore/corefacade.cpp b/src/blackcore/corefacade.cpp index b018ad93e..aa30d8b0d 100644 --- a/src/blackcore/corefacade.cpp +++ b/src/blackcore/corefacade.cpp @@ -137,6 +137,7 @@ namespace BlackCore if (this->getIContextAudio()) { handled = handled || this->getIContextAudio()->parseCommandLine(commandLine, originator); } if (this->getIContextNetwork()) { handled = handled || this->getIContextNetwork()->parseCommandLine(commandLine, originator); } if (this->getIContextOwnAircraft()) { handled = handled || this->getIContextOwnAircraft()->parseCommandLine(commandLine, originator); } + if (this->getIContextSimulator()) { handled = handled || this->getIContextSimulator()->parseCommandLine(commandLine, originator); } return handled; }