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

Pre UI refactoring #327

Merged
merged 16 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
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
17 changes: 3 additions & 14 deletions src/config/buildconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ namespace swift::config
return devBuild;
}

static QString boolToYesNo(bool v) { return v ? QStringLiteral("yes") : QStringLiteral("no"); }

const QString &CBuildConfig::compiledWithInfoShort()
const QString &CBuildConfig::compiledWithInfo()
{
static QString infoShort;
QStringList sl;
if constexpr (CBuildConfig::isCompiledWithFs9Support()) { sl << "FS9"; }
if constexpr (CBuildConfig::isCompiledWithFsxSupport()) { sl << "FSX"; }
if constexpr (CBuildConfig::isCompiledWithMSFSSupport()) { sl << "MSFS2020"; }
if constexpr (CBuildConfig::isCompiledWithMSFS2024Support()) { sl << "MSFS2024"; }
if constexpr (CBuildConfig::isCompiledWithXPlaneSupport()) { sl << "XPlane"; }
if constexpr (CBuildConfig::isCompiledWithP3DSupport()) { sl << "P3D"; }
if constexpr (CBuildConfig::isCompiledWithFGSupport()) { sl << "FG"; }
Expand All @@ -83,17 +83,6 @@ namespace swift::config
return infoShort;
}

const QString &CBuildConfig::compiledWithInfoLong()
{
static QString infoLong;
infoLong = infoLong.append(" FS9: ").append(boolToYesNo(isCompiledWithFs9Support()));
infoLong = infoLong.append(" FSX: ").append(boolToYesNo(isCompiledWithFsxSupport()));
infoLong = infoLong.append(" P3D: ").append(boolToYesNo(isCompiledWithP3DSupport()));
infoLong = infoLong.append(" XPlane: ").append(boolToYesNo(isCompiledWithXPlaneSupport()));
infoLong = infoLong.append(" FG: ").append(boolToYesNo(isCompiledWithFGSupport()));
return infoLong;
}

const QString &CBuildConfig::gitHubRepoUrl()
{
static const QString url = "https://github.com/swift-project/pilotclient/";
Expand Down
12 changes: 3 additions & 9 deletions src/config/buildconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ namespace swift::config
//! with XPlane support?
static constexpr bool isCompiledWithXPlaneSupport(); // defined in buildconfig_gen.inc.in

//! with any simulator libraries
static constexpr bool isCompiledWithFlightSimulatorSupport();

//! Debug build?
static constexpr bool isDebugBuild();

Expand All @@ -66,14 +63,11 @@ namespace swift::config
//! Running on Unix (Linux or Mac OS X) platform
static constexpr bool isRunningOnUnixPlatform();

//! Info such as Win32, Win64, MacOs, Linux
//! Info such as Win32, Win64, macOS, Linux
static const QString &getPlatformString();

//! Info string about compilation (short version)
static const QString &compiledWithInfoShort();

//! Info string about compilation (long version)
static const QString &compiledWithInfoLong();
//! Info string about compilation
static const QString &compiledWithInfo();

//! Executable name for swift GUI, no(!) appendix
static const QString &swiftGuiExecutableName();
Expand Down
5 changes: 0 additions & 5 deletions src/config/buildconfig.inc
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ namespace swift::config
return CBuildConfig::isCompiledWithFs9Support() || CBuildConfig::isCompiledWithFsxSupport() || CBuildConfig::isCompiledWithP3DSupport() || isCompiledWithMSFSSupport() || isCompiledWithMSFS2024Support();
}

constexpr bool CBuildConfig::isCompiledWithFlightSimulatorSupport()
{
return CBuildConfig::isCompiledWithMsFlightSimulatorSupport() || CBuildConfig::isCompiledWithXPlaneSupport() || CBuildConfig::isCompiledWithFGSupport();
}

constexpr bool CBuildConfig::isRunningOnWindowsNtPlatform()
{
#ifdef Q_OS_WIN
Expand Down
9 changes: 3 additions & 6 deletions src/core/afv/audio/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,8 @@ namespace swift::core::afv::audio
CMacOSMicrophoneAccess::AuthorizationStatus status = m_micAccess.getAuthorizationStatus();
if (status == CMacOSMicrophoneAccess::Authorized)
{
m_audioInput->start(m_audioInputBuffer);
connect(m_audioInputBuffer, &CAudioInputBuffer::frameAvailable, this, &CInput::audioInDataAvailable);
m_started = true;
return;
// void
// Audio start will be handled below
}
else if (status == CMacOSMicrophoneAccess::NotDetermined)
{
Expand All @@ -123,11 +121,10 @@ namespace swift::core::afv::audio
CLogMessage(this).error(u"Microphone access not granted. Voice input will not work.");
return;
}
#else
#endif
m_audioInput->start(m_audioInputBuffer);
connect(m_audioInputBuffer, &CAudioInputBuffer::frameAvailable, this, &CInput::audioInDataAvailable);
m_started = true;
#endif
const QString format = toQString(m_inputFormat);
CLogMessage(this).info(u"Starting: '%1' with: %2") << selectedDevice.description() << format;
}
Expand Down
3 changes: 0 additions & 3 deletions src/core/afv/clients/afvclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1329,9 +1329,6 @@ namespace swift::core::afv::clients
// void rounding issues from float/double
quint32 roundedFrequencyHz = static_cast<quint32>(qRound(frequencyHz / 1000.0)) * 1000;

// disabled?
if (!m_enableAliased) { return roundedFrequencyHz; }

// change to aliased frequency if needed
{
QMutexLocker lock(&m_mutex);
Expand Down
27 changes: 15 additions & 12 deletions src/core/afv/clients/afvclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "misc/audio/audiosettings.h"
#include "misc/aviation/comsystem.h"
#include "misc/identifiable.h"
#include "misc/logcategories.h"
#include "misc/settingscache.h"
#include "misc/worker.h"
#include "sound/sampleprovider/volumesampleprovider.h"
Expand Down Expand Up @@ -61,7 +60,19 @@ namespace swift::core::afv::clients
CAfvClient(const QString &apiServer, QObject *owner);

//! Dtor
virtual ~CAfvClient() override { this->stopAudio(); }
~CAfvClient() override { this->stopAudio(); }

//! @{
//! Copy operations
CAfvClient(const CAfvClient &) = delete;
CAfvClient &operator=(const CAfvClient &) = delete;
//! }@

//! @{
//! Move operations
CAfvClient(const CAfvClient &&) = delete;
CAfvClient &operator=(const CAfvClient &&) = delete;
//! }@

//! @{
//! Corresponding callsign
Expand Down Expand Up @@ -179,13 +190,6 @@ namespace swift::core::afv::clients
QSet<quint16> getEnabledTransceivers() const;
//! @}

//! @{
//! Aliased stations enabled?
//! \threadsafe
bool isAliasedStationsEnabled() const { return m_enableAliased; }
void enableAliasedStations(bool enabled) { m_enableAliased = enabled; }
//! @}

//! @{
//! Update frequency
//! \threadsafe
Expand Down Expand Up @@ -318,10 +322,10 @@ namespace swift::core::afv::clients

protected:
//! \copydoc swift::misc::CContinuousWorker::initialize
virtual void initialize() override;
void initialize() override;

//! \copydoc swift::misc::CContinuousWorker::cleanup
virtual void cleanup() override;
void cleanup() override;

private:
void opusDataAvailable(const audio::OpusDataAvailableArgs &args); // threadsafe
Expand Down Expand Up @@ -411,7 +415,6 @@ namespace swift::core::afv::clients
std::atomic_int m_heartBeatFailures { 0 }; //!< voice server heartbeat failures
std::atomic_bool m_isStarted { false };
std::atomic_bool m_loopbackOn { false };
std::atomic_bool m_enableAliased { true };
std::atomic_bool m_winCoInitialized { false }; //!< Windows only CoInitializeEx
std::atomic_bool m_integratedComUnit { false }; //!< is COM unit sychronized, integrated?

Expand Down
43 changes: 1 addition & 42 deletions src/core/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,47 +257,6 @@ namespace swift::core
return s;
}

QString CApplication::getExecutableForApplication(CApplicationInfo::Application application) const
{
QString searchFor;
switch (application)
{
case CApplicationInfo::PilotClientCore: searchFor = "core"; break;
case CApplicationInfo::Launcher: searchFor = "launcher"; break;
case CApplicationInfo::MappingTool: searchFor = "data"; break;
case CApplicationInfo::PilotClientGui: searchFor = "gui"; break;
default: break;
}
if (searchFor.isEmpty()) { return {}; }

for (const QString &executable : CFileUtils::getSwiftExecutables())
{
if (!executable.contains("swift", Qt::CaseInsensitive)) { continue; }
if (executable.contains(searchFor, Qt::CaseInsensitive)) { return executable; }
}
return {};
}

bool CApplication::startLauncher()
{
static const QString launcher =
CApplication::getExecutableForApplication(CApplicationInfo::Application::Launcher);
if (launcher.isEmpty() || CApplication::isApplicationRunning(CApplicationInfo::Launcher)) { return false; }

// const QStringList args = this->argumentsJoined({}, { "--dbus", "--core", "--coreaudio" });
const QStringList args = this->argumentsJoined({}, { "--dbus", "--core" });
return QProcess::startDetached(launcher, args);
}

bool CApplication::startLauncherAndQuit()
{
const bool started = CApplication::startLauncher();
if (!started) { return false; }
this->gracefulShutdown();
CApplication::exit();
return true;
}

CGlobalSetup CApplication::getGlobalSetup() const
{
if (m_shutdown) { return CGlobalSetup(); }
Expand Down Expand Up @@ -507,7 +466,7 @@ namespace swift::core
boolToYesNo(CBuildConfig::isRunningOnUnixPlatform()) % separator % u"MacOS: " %
boolToYesNo(CBuildConfig::isRunningOnMacOSPlatform()) % separator % "Build Abi: " %
QSysInfo::buildAbi() % separator % u"Build CPU: " % QSysInfo::buildCpuArchitecture() % separator %
CBuildConfig::compiledWithInfoLong();
CBuildConfig::compiledWithInfo();

if (this->supportsContexts()) { str += (separator % u"Supporting contexts"); }

Expand Down
9 changes: 0 additions & 9 deletions src/core/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,6 @@
//! Version, name beta and dev info
const QString &getApplicationNameVersionDetailed() const;

//! Executable names for the given applications
QString getExecutableForApplication(swift::misc::CApplicationInfo::Application application) const;

//! Start the launcher
bool startLauncher();

//! Start the launcher and quit
bool startLauncherAndQuit();

//! Global setup
//! \threadsafe
data::CGlobalSetup getGlobalSetup() const;
Expand Down Expand Up @@ -240,10 +231,10 @@
//! \name cmd line args and parsing of command line options
//! @{

//! \copydoc QCommandLineParser::addOption

Check warning on line 234 in src/core/application.h

View workflow job for this annotation

GitHub Actions / checks

@copybrief or @copydoc target 'QCommandLineParser::addOption' not found
bool addParserOption(const QCommandLineOption &option);

//! \copydoc QCommandLineParser::addOptions

Check warning on line 237 in src/core/application.h

View workflow job for this annotation

GitHub Actions / checks

@copybrief or @copydoc target 'QCommandLineParser::addOptions' not found
bool addParserOptions(const QList<QCommandLineOption> &options);

//! CMD line argument for DBus address
Expand Down
9 changes: 9 additions & 0 deletions src/core/context/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "core/context/context.h"

#include "core/application.h"
#include "misc/dbusserver.h"
#include "misc/logcategories.h"

using namespace swift::misc;
Expand Down Expand Up @@ -70,6 +71,14 @@ namespace swift::core::context
return this->getRuntime()->getIContextSimulator();
}

void IContext::registerWithDBus(const QString &objectPath, CDBusServer *server)
{
if (!server || getMode() != CCoreFacadeConfig::LocalInDBusServer) { return; }

// remark that registers all SIGNALS, not only the interface ons
server->addObject(objectPath, this);
}

const CStatusMessage &IContext::statusMessageEmptyContext()
{
static const CStatusMessage m(static_cast<IContext *>(nullptr), CStatusMessage::SeverityWarning,
Expand Down
3 changes: 3 additions & 0 deletions src/core/context/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ namespace swift::core::context
//! Called when shutdown is about to be called
virtual void onAboutToShutdown() {}

//! Register myself in DBus
void registerWithDBus(const QString &objectPath, misc::CDBusServer *server);

//! Standard message when status message is returned in empty context
static const misc::CStatusMessage &statusMessageEmptyContext();

Expand Down
2 changes: 1 addition & 1 deletion src/core/context/contextapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace swift::core::context
case CCoreFacadeConfig::LocalInDBusServer:
{
auto *context = new CContextApplication(mode, parent);
context->registerWithDBus(server);
context->registerWithDBus(ObjectPath(), server);
return context;
}
case CCoreFacadeConfig::Remote:
Expand Down
6 changes: 0 additions & 6 deletions src/core/context/contextapplicationimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ namespace swift::core::context
: IContextApplication(mode, runtime), CIdentifiable(this)
{}

void CContextApplication::registerWithDBus(swift::misc::CDBusServer *server)
{
if (!server || getMode() != CCoreFacadeConfig::LocalInDBusServer) { return; }
server->addObject(IContextApplication::ObjectPath(), this);
}

void CContextApplication::changeSettings(const CValueCachePacket &settings, const CIdentifier &origin)
{
// Intentionally don't check for round trip here
Expand Down
3 changes: 0 additions & 3 deletions src/core/context/contextapplicationimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ namespace swift::core
//! Constructor
CContextApplication(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime);

//! Register myself in DBus, fail safe
void registerWithDBus(swift::misc::CDBusServer *server);

private:
swift::misc::CIdentifierList m_registeredApplications;

Expand Down
19 changes: 6 additions & 13 deletions src/core/context/contextaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace swift::core::context
case CCoreFacadeConfig::LocalInDBusServer:
{
auto *context = new CContextAudio(mode, runtime);
context->registerWithDBus(server);
context->registerWithDBus(ObjectPath(), server);
return context;
}
case CCoreFacadeConfig::Remote:
Expand All @@ -80,10 +80,11 @@ namespace swift::core::context
{
Q_UNUSED(originator)
if (commandLine.isEmpty()) { return false; }
CSimpleCommandParser parser({ ".vol", ".volume", // output volume
".mute", // mute
".unmute", // unmute
".aliased" });
CSimpleCommandParser parser({
".vol", ".volume", // output volume
".mute", // mute
".unmute", // unmute
});
parser.parse(commandLine);
if (!parser.isKnownCommand()) { return false; }

Expand All @@ -103,14 +104,6 @@ namespace swift::core::context
this->setMasterOutputVolume(v);
return true;
}
else if (afvClient() && parser.matchesCommand(".aliased") && parser.countParts() > 1)
{
const bool enable = parser.toBool(1, true);
afvClient()->enableAliasedStations(enable);

CLogMessage(this).info(u"Aliased stations are: %1") << boolToOnOff(enable);
return true;
}
return false;
}

Expand Down
Loading
Loading