mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Remove unused FGSettingsWriter
This commit is contained in:
committed by
Mat Sutcliffe
parent
0d77f9d41c
commit
37cdb2e246
@@ -1,84 +0,0 @@
|
||||
/* Copyright (C) 2018
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
|
||||
* or distributed except according to the terms contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#include "fgswiftbusconfigwriter.h"
|
||||
#include "blackmisc/simulation/xplane/xplaneutil.h"
|
||||
#include "blackmisc/dbusserver.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
namespace Flightgear
|
||||
{
|
||||
CFGSwiftBusConfigWriter::CFGSwiftBusConfigWriter(QObject *parent) : QObject(parent)
|
||||
{ }
|
||||
|
||||
void CFGSwiftBusConfigWriter::setDBusAddress(const QString &dBusAddress)
|
||||
{
|
||||
if (CDBusServer::isSessionOrSystemAddress(dBusAddress)) { m_dbusMode = "session"; }
|
||||
else { m_dbusMode = "p2p"; }
|
||||
|
||||
if (m_dbusMode == "p2p")
|
||||
{
|
||||
CDBusServer::dBusAddressToHostAndPort(dBusAddress, m_dbusAddress, m_dbusPort);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CFGSwiftBusConfigWriter::updateInAllXPlaneVersions()
|
||||
{
|
||||
updateInXPlane9();
|
||||
updateInXPlane10();
|
||||
updateInXPlane11();
|
||||
}
|
||||
|
||||
void CFGSwiftBusConfigWriter::updateInXPlane9()
|
||||
{
|
||||
//QString path = CXPlaneUtil::xswiftbusPluginDir(CXPlaneUtil::xplane9Dir());
|
||||
//if (!path.isEmpty()) { writeTo(path); }
|
||||
}
|
||||
|
||||
void CFGSwiftBusConfigWriter::updateInXPlane10()
|
||||
{
|
||||
//QString path = CXPlaneUtil::xswiftbusPluginDir(CXPlaneUtil::xplane10Dir());
|
||||
//if (!path.isEmpty()) { writeTo(path); }
|
||||
}
|
||||
|
||||
void CFGSwiftBusConfigWriter::updateInXPlane11()
|
||||
{
|
||||
//QString path = CXPlaneUtil::xswiftbusPluginDir(CXPlaneUtil::xplane11Dir());
|
||||
//if (!path.isEmpty()) { writeTo(path); }
|
||||
}
|
||||
|
||||
void CFGSwiftBusConfigWriter::writeTo(const QString &filePath)
|
||||
{
|
||||
QString configFilePath = filePath + "/xswiftbus.conf";
|
||||
QFile configFile(configFilePath);
|
||||
configFile.remove();
|
||||
if (configFile.open(QIODevice::WriteOnly))
|
||||
{
|
||||
QTextStream ts(&configFile);
|
||||
ts << "# DBus Mode - Options: p2p, session" << endl;
|
||||
ts << "dbusMode = " << m_dbusMode << endl;
|
||||
ts << endl;
|
||||
ts << "# DBus server address - relevant for P2P mode only" << endl;
|
||||
ts << "dbusAddress = " << m_dbusAddress << endl;
|
||||
ts << endl;
|
||||
ts << "# DBus server port - relevant for P2P mode only" << endl;
|
||||
ts << "dbusPort = " << m_dbusPort << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/* Copyright (C) 2018
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
|
||||
* or distributed except according to the terms contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_SIMULATION_FLIGHTGEAR_FGSWIFTBUSCONFIGWRITER_H
|
||||
#define BLACKMISC_SIMULATION_FLIGHTGEAR_FGSWIFTBUSCONFIGWRITER_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
namespace Flightgear
|
||||
{
|
||||
//! FGSwiftBus configuration file writer
|
||||
class BLACKMISC_EXPORT CFGSwiftBusConfigWriter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Default constructor.
|
||||
CFGSwiftBusConfigWriter(QObject *parent = nullptr);
|
||||
|
||||
//! Set new DBus address
|
||||
void setDBusAddress(const QString &dBusAddress);
|
||||
|
||||
//! Update fgswiftbus.conf in all known X-Plane versions (XP9 - XP11 are supported)
|
||||
void updateInAllXPlaneVersions();
|
||||
|
||||
//! Update xswiftbus.conf in X-Plane 9
|
||||
void updateInXPlane9();
|
||||
|
||||
//! Update xswiftbus.conf in X-Plane 10
|
||||
void updateInXPlane10();
|
||||
|
||||
//! Update xswiftbus.conf in X-Plane 11
|
||||
void updateInXPlane11();
|
||||
|
||||
//! Write new xswiftbus.conf to filePath. Existing files are removed.
|
||||
void writeTo(const QString &filePath);
|
||||
|
||||
private:
|
||||
QString m_dbusMode = "p2p";
|
||||
QString m_dbusAddress = "127.0.0.1";
|
||||
QString m_dbusPort = "45001";
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -31,7 +31,7 @@ namespace BlackMisc
|
||||
static const char *key() { return "fgswiftbus/server"; }
|
||||
|
||||
//! \copydoc BlackCore::TSettingTrait::humanReadable
|
||||
static const QString &humanReadable() { static const QString name("FGSiftBus"); return name; }
|
||||
static const QString &humanReadable() { static const QString name("FGSwiftBus"); return name; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::defaultValue
|
||||
static QString defaultValue() { return "tcp:host=127.0.0.1,port=45003"; }
|
||||
|
||||
@@ -9,14 +9,13 @@
|
||||
#include "simulatorflightgearconfigwindow.h"
|
||||
#include "blackcore/application.h"
|
||||
#include "ui_simulatorflightgearconfigwindow.h"
|
||||
#include "blackmisc/simulation/flightgear/fgswiftbusconfigwriter.h"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
using namespace BlackGui;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation::Flightgear;
|
||||
//using namespace BlackMisc::Simulation::Flightgear;
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
@@ -44,9 +43,6 @@ namespace BlackSimPlugin
|
||||
if (currentAddress != ui->comp_SettingsFGSwiftBus->getDBusAddress())
|
||||
{
|
||||
m_fgswiftbusServerSetting.set(updatedAddress);
|
||||
CFGSwiftBusConfigWriter fgswiftbusConfigWriter;
|
||||
fgswiftbusConfigWriter.setDBusAddress(updatedAddress);
|
||||
fgswiftbusConfigWriter.updateInAllXPlaneVersions();
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user