refs #297 Removed old network settings.

This commit is contained in:
Mathew Sutcliffe
2015-06-30 20:59:25 +01:00
parent bacf771a15
commit 3037daed1d
13 changed files with 2 additions and 315 deletions

View File

@@ -41,7 +41,6 @@ namespace BlackCore
IContextNetwork(mode, runtime)
{
Q_ASSERT(this->getRuntime());
Q_ASSERT(this->getIContextSettings());
Q_ASSERT(this->getIContextOwnAircraft());
Q_ASSERT(this->getIContextOwnAircraft()->isUsingImplementingObject());

View File

@@ -21,7 +21,6 @@
#include "blackmisc/simulation/remoteaircraftprovider.h"
#include "blackmisc/aviation/atcstationlist.h"
#include "blackmisc/aviation/aircraftsituationlist.h"
#include "blackmisc/setnetwork.h"
#include "blackmisc/network/clientlist.h"
#include "blackmisc/digestsignal.h"
#include "blackmisc/logmessage.h"
@@ -248,14 +247,6 @@ namespace BlackCore
CIcaoDataReader *m_icaoDataReader = nullptr;
QTimer *m_dataUpdateTimer = nullptr; //!< general updates such as ATIS, frequencies, see requestDataUpdates()
//! Get network settings
BlackMisc::Settings::CSettingsNetwork getNetworkSettings() const
{
Q_ASSERT(this->getRuntime());
Q_ASSERT(this->getRuntime()->getIContextSettings());
return this->getRuntime()->getIContextSettings()->getNetworkSettings();
}
//! Own aircraft from \sa CContextOwnAircraft
const BlackMisc::Simulation::CSimulatedAircraft ownAircraft() const;

View File

@@ -77,16 +77,6 @@ namespace BlackCore
//! \copydoc CContext::getPathAndContextId()
virtual QString getPathAndContextId() const { return this->buildPathAndContextId(ObjectPath()); }
/*!
* \brief Path for network settings
* \remarks no to be confused with DBus paths
*/
static const QString &PathNetworkSettings()
{
static QString s("network");
return s;
}
//! Path for audio settings
static const QString &PathAudioSettings()
{
@@ -123,9 +113,6 @@ namespace BlackCore
//! Handle value
virtual BlackMisc::CStatusMessageList value(const QString &path, const QString &command, const BlackMisc::CVariant &value) = 0;
//! Network settings
virtual BlackMisc::Settings::CSettingsNetwork getNetworkSettings() const = 0;
//! Audio settings
virtual BlackMisc::Settings::CSettingsAudio getAudioSettings() const = 0;

View File

@@ -14,7 +14,6 @@
using namespace BlackMisc;
using namespace BlackMisc::Settings;
using namespace BlackMisc::Network;
using namespace BlackMisc::Hardware;
namespace BlackCore
@@ -46,18 +45,6 @@ namespace BlackCore
}
jsonFile.close();
// init network
if (jsonObject.contains(IContextSettings::PathNetworkSettings()))
{
this->m_settingsNetwork.convertFromJson(
jsonObject.value(IContextSettings::PathNetworkSettings()).toObject()
);
}
else
{
this->m_settingsNetwork.initDefaultValues();
}
// init audio
if (jsonObject.contains(IContextSettings::PathAudioSettings()))
{
@@ -122,7 +109,6 @@ namespace BlackCore
CStatusMessage CContextSettings::reset(bool write)
{
this->m_hotkeys.initAsHotkeyList(true);
this->m_settingsNetwork.initDefaultValues();
this->m_settingsAudio.initDefaultValues();
this->emitCompletelyChanged();
if (write)
@@ -147,7 +133,6 @@ namespace BlackCore
QJsonDocument CContextSettings::toJsonDocument() const
{
QJsonObject jsonObject;
jsonObject.insert(IContextSettings::PathNetworkSettings(), this->m_settingsNetwork.toJson());
jsonObject.insert(IContextSettings::PathAudioSettings(), this->m_settingsAudio.toJson());
jsonObject.insert(IContextSettings::PathHotkeys(), this->m_hotkeys.toJson());
QJsonDocument doc(jsonObject);
@@ -173,14 +158,6 @@ namespace BlackCore
return this->m_hotkeys;
}
/*
* Network settings
*/
CSettingsNetwork CContextSettings::getNetworkSettings() const
{
return this->m_settingsNetwork;
}
/*
* Audio settings
*/
@@ -215,18 +192,9 @@ namespace BlackCore
// next level
QString nextLevelPath = CSettingUtilities::removeLeadingPath(path);
bool changed = false;
if (path.startsWith(IContextSettings::PathNetworkSettings()))
{
msgs.push_back(this->m_settingsNetwork.value(nextLevelPath, command, value, changed));
if (changed)
{
msgs.push_back(this->write());
emit this->changedSettings(static_cast<uint>(SettingsNetwork));
}
}
else if (path.startsWith(IContextSettings::PathAudioSettings()))
if (path.startsWith(IContextSettings::PathAudioSettings()))
{
bool changed = false;
msgs.push_back(this->m_settingsAudio.value(nextLevelPath, command, value, changed));
if (changed)
{

View File

@@ -54,9 +54,6 @@ namespace BlackCore
virtual BlackMisc::CStatusMessageList value(const QString &path, const QString &command, const BlackMisc::CVariant &value) override;
public slots:
//! \copydoc IContextSettings::getNetworkSettings()
virtual BlackMisc::Settings::CSettingsNetwork getNetworkSettings() const override;
//! \copydoc IContextSettings::getAudioSettings()
virtual BlackMisc::Settings::CSettingsAudio getAudioSettings() const override;
@@ -82,7 +79,6 @@ namespace BlackCore
//! settings directory
const QString &getSettingsDirectory() const { return BlackMisc::Settings::CSettingUtilities::getSettingsDirectory(); }
BlackMisc::Settings::CSettingsNetwork m_settingsNetwork;
BlackMisc::Settings::CSettingsAudio m_settingsAudio;
BlackMisc::Settings::CSettingKeyboardHotkeyList m_hotkeys;
QJsonDocument toJsonDocument() const;

View File

@@ -41,14 +41,6 @@ namespace BlackCore
Q_UNUSED(s);
}
/*
* Relay to DBus
*/
CSettingsNetwork CContextSettingsProxy::getNetworkSettings() const
{
return this->m_dBusInterface->callDBusRet<CSettingsNetwork>(QLatin1Literal("getNetworkSettings"));
}
/*
* Relay to DBus
*/

View File

@@ -12,7 +12,6 @@
#include "blackmisc/statusmessagelist.h"
#include "blackmisc/genericdbusinterface.h"
#include "blackmisc/settingutilities.h"
#include "blackmisc/setnetwork.h"
#include "blackmisc/hardware/keyboardkeylist.h"
namespace BlackCore
@@ -44,9 +43,6 @@ namespace BlackCore
CContextSettingsProxy(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextSettings(mode, runtime), m_dBusInterface(nullptr) {}
public slots:
//! \copydoc IContextSettings::getNetworkSettings()
virtual BlackMisc::Settings::CSettingsNetwork getNetworkSettings() const override;
//! \copydoc IContextSettings::getAudioSettings()
virtual BlackMisc::Settings::CSettingsAudio getAudioSettings() const override;

View File

@@ -42,12 +42,6 @@ namespace BlackGui
CSettingsNetworkServersComponent::~CSettingsNetworkServersComponent()
{ }
void CSettingsNetworkServersComponent::runtimeHasBeenSet()
{
Q_ASSERT_X(this->getIContextSettings(), Q_FUNC_INFO, "Missing settings");
this->connect(this->getIContextSettings(), &IContextSettings::changedSettings, this, &CSettingsNetworkServersComponent::ps_changedSettings);
}
void CSettingsNetworkServersComponent::reloadSettings()
{
// update servers
@@ -85,12 +79,5 @@ namespace BlackGui
m_trafficNetworkServers.set(serverList);
}
void CSettingsNetworkServersComponent::ps_changedSettings(uint typeValue)
{
IContextSettings::SettingsType type = static_cast<IContextSettings::SettingsType>(typeValue);
Q_UNUSED(type);
}
} // namespace
} // namespace

View File

@@ -38,10 +38,6 @@ namespace BlackGui
//! Destructor
~CSettingsNetworkServersComponent();
protected:
//! \copydoc CRuntimeBasedComponent::runtimeHasBeenSet
virtual void runtimeHasBeenSet() override;
public slots:
//! Reload settings
void reloadSettings();
@@ -53,9 +49,6 @@ namespace BlackGui
//! Alter traffic server
void ps_alterTrafficServer();
//! Changed settings
void ps_changedSettings(uint typeValue);
private:
QScopedPointer<Ui::CSettingsNetworkServersComponent> ui;

View File

@@ -50,7 +50,6 @@ void BlackMisc::Geo::registerMetadata()
*/
void BlackMisc::Settings::registerMetadata()
{
CSettingsNetwork::registerMetadata();
CSettingsAudio::registerMetadata();
CSettingKeyboardHotkey::registerMetadata();
CSettingKeyboardHotkeyList::registerMetadata();

View File

@@ -1,103 +0,0 @@
/* Copyright (C) 2013
* 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 and at http://www.swift-project.org/license.html. 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.
*/
#include "setnetwork.h"
#include "blackmisc/blackmiscfreefunctions.h"
#include "blackmisc/statusmessagelist.h"
#include "blackmisc/settingutilities.h"
#include "blackmisc/variant.h"
#include "blackmisc/logmessage.h"
using namespace BlackMisc::Network;
namespace BlackMisc
{
namespace Settings
{
/*
* Constructor
*/
CSettingsNetwork::CSettingsNetwork() :
m_bookingServiceUrl("http://vatbook.euroutepro.com/xml2.php"),
m_dbusServerAddress(sessionDBusServer())
{
// settings
}
bool CSettingsNetwork::setCurrentNetworkServer(const CServer &currentServer)
{
if (this->m_trafficNetworkServerCurrent == currentServer) return false;
m_trafficNetworkServerCurrent = currentServer;
return true;
}
/*
* Convert to string
*/
QString CSettingsNetwork::convertToQString(bool i18n) const
{
QString s("Traffic servers:");
s.append(" ").append(this->m_trafficNetworkServers.toQString(i18n));
return s;
}
/*
* Default values
*/
void CSettingsNetwork::initDefaultValues()
{
this->m_trafficNetworkServers.clear();
this->addTrafficNetworkServer(CServer("Testserver", "Client project testserver", "vatsim-germany.org", 6809, CUser("guest", "Guest Client project", "", "guest")));
}
/*
* Value
*/
BlackMisc::CStatusMessage CSettingsNetwork::value(const QString &path, const QString &command, const CVariant &value, bool &changedFlag)
{
// TODO: This needs to be refactored to a smarter way to delegate commands
changedFlag = false;
if (path == CSettingsNetwork::ValueTrafficServers())
{
const CServer server = value.value<CServer>();
if (command == CSettingsNetwork::CmdSetCurrentServer())
{
changedFlag = this->setCurrentNetworkServer(server);
if (changedFlag)
{
// make sure the server is correct int the list too
this->m_trafficNetworkServers.replaceOrAdd(&CServer::getName, server.getName(), server);
}
}
else if (command == CSettingUtilities::CmdUpdate())
{
this->m_trafficNetworkServers.replaceOrAdd(&CServer::getName, server.getName(), server);
changedFlag = true;
}
else if (command == CSettingUtilities::CmdRemove())
{
changedFlag = this->m_trafficNetworkServers.contains(&CServer::getName, server.getName());
this->m_trafficNetworkServers.removeIf(&CServer::getName, server.getName());
}
return CLogMessage(CLogCategory::settingsUpdate()).info("Set current server");
}
else if (path == CSettingsNetwork::ValueBookingServiceUrl())
{
if (command == CSettingUtilities::CmdUpdate())
{
QString v = value.toQString();
changedFlag = (v != this->m_bookingServiceUrl);
this->m_bookingServiceUrl = v;
return CLogMessage(CLogCategory::settingsUpdate()).info("booking URL%1 changed") << (changedFlag ? "" : " not");
}
}
return CLogMessage(CLogCategory::validation()).error("wrong path: %1") << path;
}
} // namespace
} // namespace

View File

@@ -1,117 +0,0 @@
/* Copyright (C) 2013
* 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 and at http://www.swift-project.org/license.html. 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_SETTINGS_NETWORK_H
#define BLACKMISC_SETTINGS_NETWORK_H
#include "blackmiscexport.h"
#include "network/serverlist.h"
#include "valueobject.h"
#include "statusmessagelist.h"
#include "settingutilities.h"
#include <QJsonObject>
namespace BlackMisc
{
class CVariant;
namespace Settings
{
//! Value object encapsulating information of network related settings.
//! \remarks Not only traffic network settings, but also URLs, DBus address, ...
class BLACKMISC_EXPORT CSettingsNetwork : public CValueObject<CSettingsNetwork>
{
public:
//! Default constructor.
CSettingsNetwork();
//! Destructor.
virtual ~CSettingsNetwork() {}
//! Current server
//! \deprecated shall not be used anymore
static const QString &CmdSetCurrentServer()
{
static const QString cmd("currenttrafficserver");
return cmd;
}
//! Path
static const QString &ValueTrafficServers()
{
static const QString value("trafficservers");
return value;
}
//! Path
static const QString &ValueBookingServiceUrl()
{
static const QString value("bookingserviceurl");
return value;
}
//! Path
static const QString &ValueDBusServerAddress()
{
static const QString value("dbuserveraddress");
return value;
}
//! Denotes a session DBus server
static const QString &sessionDBusServer()
{
static QString session("session");
return session;
}
//! Value object, traffic network server objects
BlackMisc::Network::CServerList getTrafficNetworkServers() const { return m_trafficNetworkServers; }
//! Selected traffic network server
//! \deprecated Shall not be used anymore
BlackMisc::Network::CServer getCurrentTrafficNetworkServer() const { return m_trafficNetworkServerCurrent; }
//! URL of booking service
QString getBookingServiceUrl() const { return m_bookingServiceUrl; }
//! Address for DBus Server
QString getDBusServerAddress() const { return m_dbusServerAddress; }
//! Selected traffic network server
bool setCurrentNetworkServer(const BlackMisc::Network::CServer &currentServer);
//! Traffic network server objects
void addTrafficNetworkServer(const BlackMisc::Network::CServer &server) { m_trafficNetworkServers.push_back(server); }
//! \copydoc BlackCore::IContextSettings::value
BlackMisc::CStatusMessage value(const QString &path, const QString &command, const CVariant &value, bool &changedFlag);
//! Init with meaningful default values
void initDefaultValues();
//! \copydoc CValueObject::convertToQString
QString convertToQString(bool i18n = false) const;
private:
BLACK_ENABLE_TUPLE_CONVERSION(CSettingsNetwork)
BlackMisc::Network::CServerList m_trafficNetworkServers;
BlackMisc::Network::CServer m_trafficNetworkServerCurrent;
QString m_bookingServiceUrl;
QString m_dbusServerAddress;
};
} // namespace
} // namespace
Q_DECLARE_METATYPE(BlackMisc::Settings::CSettingsNetwork)
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Settings::CSettingsNetwork, (o.m_trafficNetworkServers, o.m_trafficNetworkServerCurrent, o.m_bookingServiceUrl, o.m_dbusServerAddress))
#endif // guard

View File

@@ -2,7 +2,6 @@
#define BLACKMISC_SETTINGSBLACKMISCCLASSES_H
#include "blackmisc/setaudio.h"
#include "blackmisc/setnetwork.h"
#include "blackmisc/setkeyboardhotkeylist.h"
#endif // guard