Refactoring
This commit is contained in:
parent
e82d2e5e4a
commit
e2e36e698c
6 changed files with 28 additions and 26 deletions
|
@ -18,7 +18,7 @@ BluetoothLinkProvider::BluetoothLinkProvider(bool isDisabled)
|
|||
, mServiceDiscoveryAgent(new QBluetoothServiceDiscoveryAgent(this))
|
||||
, connectTimer(new QTimer(this))
|
||||
{
|
||||
this->disabled = isDisabled;
|
||||
this->mDisabled = isDisabled;
|
||||
connectTimer->setInterval(30000);
|
||||
connectTimer->setSingleShot(false);
|
||||
|
||||
|
@ -33,7 +33,7 @@ BluetoothLinkProvider::BluetoothLinkProvider(bool isDisabled)
|
|||
void BluetoothLinkProvider::onStart()
|
||||
{
|
||||
qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::onStart executed";
|
||||
if (!disabled) {
|
||||
if (!mDisabled) {
|
||||
tryToInitialise();
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ void BluetoothLinkProvider::tryToInitialise()
|
|||
|
||||
void BluetoothLinkProvider::onStop()
|
||||
{
|
||||
if (!disabled) {
|
||||
if (!mDisabled) {
|
||||
qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::onStop executed";
|
||||
if (!mBluetoothServer) {
|
||||
return;
|
||||
|
@ -76,17 +76,17 @@ void BluetoothLinkProvider::onStop()
|
|||
|
||||
void BluetoothLinkProvider::enable()
|
||||
{
|
||||
if (disabled) {
|
||||
disabled = false;
|
||||
if (mDisabled) {
|
||||
mDisabled = false;
|
||||
tryToInitialise();
|
||||
}
|
||||
}
|
||||
|
||||
void BluetoothLinkProvider::disable()
|
||||
{
|
||||
if (!disabled) {
|
||||
disabled = true;
|
||||
this->onStop();
|
||||
if (!mDisabled) {
|
||||
mDisabled = true;
|
||||
onStop();
|
||||
|
||||
mBluetoothServer = nullptr;
|
||||
mServiceDiscoveryAgent = nullptr;
|
||||
|
@ -96,7 +96,7 @@ void BluetoothLinkProvider::disable()
|
|||
void BluetoothLinkProvider::onNetworkChange()
|
||||
{
|
||||
qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::onNetworkChange executed";
|
||||
if (!disabled) {
|
||||
if (!mDisabled) {
|
||||
tryToInitialise();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ private:
|
|||
QBluetoothServiceInfo mKdeconnectService;
|
||||
QBluetoothServiceDiscoveryAgent *mServiceDiscoveryAgent;
|
||||
QTimer *connectTimer;
|
||||
bool disabled;
|
||||
bool mDisabled;
|
||||
|
||||
QMap<QString, DeviceLink *> mLinks;
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ LanLinkProvider::LanLinkProvider(bool testMode, bool isDisabled)
|
|||
, m_mdnsDiscovery(this)
|
||||
#endif
|
||||
{
|
||||
this->disabled = isDisabled;
|
||||
this->m_disabled = isDisabled;
|
||||
|
||||
m_combineNetworkChangeTimer.setInterval(0); // increase this if waiting a single event-loop iteration is not enough
|
||||
m_combineNetworkChangeTimer.setSingleShot(true);
|
||||
|
@ -88,22 +88,22 @@ LanLinkProvider::~LanLinkProvider()
|
|||
|
||||
void LanLinkProvider::enable()
|
||||
{
|
||||
if (disabled == true) {
|
||||
disabled = false;
|
||||
this->onStart();
|
||||
if (m_disabled == true) {
|
||||
m_disabled = false;
|
||||
onStart();
|
||||
}
|
||||
}
|
||||
void LanLinkProvider::disable()
|
||||
{
|
||||
if (disabled == false) {
|
||||
this->onStop();
|
||||
disabled = true;
|
||||
if (m_disabled == false) {
|
||||
onStop();
|
||||
m_disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
void LanLinkProvider::onStart()
|
||||
{
|
||||
if (disabled) {
|
||||
if (m_disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ void LanLinkProvider::onStart()
|
|||
|
||||
void LanLinkProvider::onStop()
|
||||
{
|
||||
if (disabled) {
|
||||
if (m_disabled) {
|
||||
return;
|
||||
}
|
||||
#ifdef KDECONNECT_MDNS
|
||||
|
@ -152,7 +152,7 @@ void LanLinkProvider::onStop()
|
|||
|
||||
void LanLinkProvider::onNetworkChange()
|
||||
{
|
||||
if (disabled) {
|
||||
if (m_disabled) {
|
||||
return;
|
||||
}
|
||||
if (m_combineNetworkChangeTimer.isActive()) {
|
||||
|
@ -165,7 +165,7 @@ void LanLinkProvider::onNetworkChange()
|
|||
// I'm in a new network, let's be polite and introduce myself
|
||||
void LanLinkProvider::combinedOnNetworkChange()
|
||||
{
|
||||
if (disabled) {
|
||||
if (m_disabled) {
|
||||
return;
|
||||
}
|
||||
if (!m_server->isListening()) {
|
||||
|
|
|
@ -95,7 +95,7 @@ private:
|
|||
const bool m_testMode;
|
||||
QTimer m_combineNetworkChangeTimer;
|
||||
|
||||
bool disabled;
|
||||
bool m_disabled;
|
||||
|
||||
#ifdef KDECONNECT_MDNS
|
||||
MdnsDiscovery m_mdnsDiscovery;
|
||||
|
|
|
@ -157,7 +157,7 @@ QStringList Daemon::linkProviders() const
|
|||
QStringList returnValue;
|
||||
|
||||
for (LinkProvider *a : std::as_const(d->m_linkProviders)) {
|
||||
QString line = QString(a->name());
|
||||
QString line(a->name());
|
||||
|
||||
if (status[QStringLiteral("enabled")].contains(a->name())) {
|
||||
line += QStringLiteral("|enabled");
|
||||
|
@ -184,7 +184,7 @@ void Daemon::setProviderStatus(const QStringList &providerStatus)
|
|||
QString providerName = components.at(0);
|
||||
QString providerStatus = components.at(1);
|
||||
|
||||
auto linkProviders = this->getLinkProviders();
|
||||
const auto linkProviders = this->getLinkProviders();
|
||||
for (LinkProvider *provider : linkProviders) {
|
||||
if (provider->name() == providerName) {
|
||||
if (providerStatus == QStringLiteral("enabled")) {
|
||||
|
|
|
@ -85,8 +85,10 @@ void KdeConnectConfig::setLinkProviderStatus(const QStringList enabledProviders,
|
|||
|
||||
QMap<QString, QStringList> KdeConnectConfig::linkProviderStatus() const
|
||||
{
|
||||
return {{QStringLiteral("enabled"), d->m_config->value(QStringLiteral("enabled_providers")).toStringList()},
|
||||
{QStringLiteral("disabled"), d->m_config->value(QStringLiteral("disabled_providers")).toStringList()}};
|
||||
return {
|
||||
{QStringLiteral("enabled"), d->m_config->value(QStringLiteral("enabled_providers")).toStringList()},
|
||||
{QStringLiteral("disabled"), d->m_config->value(QStringLiteral("disabled_providers")).toStringList()},
|
||||
};
|
||||
}
|
||||
|
||||
DeviceType KdeConnectConfig::deviceType()
|
||||
|
|
Loading…
Reference in a new issue