From 9c87393b288720ab2cf01b911e72ec5c56a6916f Mon Sep 17 00:00:00 2001 From: Albert Vaca Cintora Date: Sun, 16 Jul 2023 16:20:34 +0200 Subject: [PATCH] clang-format pass --- app/main.cpp | 2 +- core/backends/devicelink.cpp | 1 - core/backends/lan/lanlinkprovider.cpp | 12 +--- core/backends/pairinghandler.cpp | 67 ++++++++++--------- core/backends/pairinghandler.h | 7 +- core/daemon.cpp | 1 - core/device.cpp | 3 +- core/filetransferjob.cpp | 4 +- core/pairstate.h | 1 - core/pluginloader.cpp | 16 ++--- daemon/kdeconnectd.cpp | 2 +- indicator/indicatorhelper_win.cpp | 10 +-- interfaces/dbusinterfaces.cpp | 14 ++-- interfaces/dbusinterfaces.h | 8 +-- kcm/kcm.cpp | 1 - kcm/kcm.h | 1 - plugins/clipboard/clipboard_config.cpp | 2 +- plugins/clipboard/clipboard_config.h | 11 ++- plugins/notifications/notification.cpp | 4 +- plugins/notifications/notification.h | 2 +- .../remotekeyboard/remotekeyboardplugin.cpp | 7 +- plugins/runcommand/runcommand_config.cpp | 4 +- .../notifyingapplicationmodel.cpp | 2 +- .../systemvolume/systemvolumeplugin-win.cpp | 1 - 24 files changed, 86 insertions(+), 97 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index 2a8fcb2e4..88babef55 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -13,11 +13,11 @@ #include #include +#include "kdeconnect-version.h" #include #include #include #include -#include "kdeconnect-version.h" int main(int argc, char *argv[]) { diff --git a/core/backends/devicelink.cpp b/core/backends/devicelink.cpp index 01888926e..31245b17c 100644 --- a/core/backends/devicelink.cpp +++ b/core/backends/devicelink.cpp @@ -15,4 +15,3 @@ DeviceLink::DeviceLink(const QString &deviceId, LinkProvider *parent) parent->onLinkDestroyed(deviceId, this); }); } - diff --git a/core/backends/lan/lanlinkprovider.cpp b/core/backends/lan/lanlinkprovider.cpp index cab79f91d..c7cc8633b 100644 --- a/core/backends/lan/lanlinkprovider.cpp +++ b/core/backends/lan/lanlinkprovider.cpp @@ -13,8 +13,8 @@ #include #include #else -#include #include +#include #endif #include @@ -562,15 +562,9 @@ void LanLinkProvider::configureSocket(QSslSocket *socket) DWORD nop; // see https://learn.microsoft.com/en-us/windows/win32/winsock/sio-keepalive-vals - struct tcp_keepalive keepalive = { - 1 /* true */, - maxIdle, - interval - }; + struct tcp_keepalive keepalive = {1 /* true */, maxIdle, interval}; - int rv = WSAIoctl(socket->socketDescriptor(), SIO_KEEPALIVE_VALS, &keepalive, - sizeof(keepalive), nullptr, 0, &nop, - nullptr, nullptr); + int rv = WSAIoctl(socket->socketDescriptor(), SIO_KEEPALIVE_VALS, &keepalive, sizeof(keepalive), nullptr, 0, &nop, nullptr, nullptr); if (!rv) { int error = WSAGetLastError(); qCDebug(KDECONNECT_CORE) << "Could not enable TCP Keep-Alive: " << error; diff --git a/core/backends/pairinghandler.cpp b/core/backends/pairinghandler.cpp index 3cff320e7..b7d2e39db 100644 --- a/core/backends/pairinghandler.cpp +++ b/core/backends/pairinghandler.cpp @@ -26,42 +26,42 @@ void PairingHandler::packetReceived(const NetworkPacket &np) bool wantsPair = np.get(QStringLiteral("pair")); if (wantsPair) { switch (m_pairState) { - case PairState::Requested: - pairingDone(); - break; - case PairState::RequestedByPeer: - qCDebug(KDECONNECT_CORE) << "Ignoring second pairing request before the first one timed out"; - break; - case PairState::Paired: - case PairState::NotPaired: - if (m_pairState == PairState::Paired) { - qWarning() << "Received pairing request from a device we already trusted."; - // It would be nice to auto-accept the pairing request here, but since the pairing accept and pairing request - // messages are identical, this could create an infinite loop if both devices are "accepting" each other pairs. - // Instead, unpair and handle as if "NotPaired". - m_pairState = PairState::NotPaired; - Q_EMIT unpaired(); - } - m_pairState = PairState::RequestedByPeer; - m_pairingTimeout.start(); - Q_EMIT incomingPairRequest(); - break; + case PairState::Requested: + pairingDone(); + break; + case PairState::RequestedByPeer: + qCDebug(KDECONNECT_CORE) << "Ignoring second pairing request before the first one timed out"; + break; + case PairState::Paired: + case PairState::NotPaired: + if (m_pairState == PairState::Paired) { + qWarning() << "Received pairing request from a device we already trusted."; + // It would be nice to auto-accept the pairing request here, but since the pairing accept and pairing request + // messages are identical, this could create an infinite loop if both devices are "accepting" each other pairs. + // Instead, unpair and handle as if "NotPaired". + m_pairState = PairState::NotPaired; + Q_EMIT unpaired(); + } + m_pairState = PairState::RequestedByPeer; + m_pairingTimeout.start(); + Q_EMIT incomingPairRequest(); + break; } } else { // wantsPair == false qCDebug(KDECONNECT_CORE) << "Unpair request received"; switch (m_pairState) { - case PairState::NotPaired: - qCDebug(KDECONNECT_CORE) << "Ignoring unpair request for already unpaired device"; - break; - case PairState::Requested: // We started pairing and got rejected - case PairState::RequestedByPeer: // They stared pairing, then cancelled - m_pairState = PairState::NotPaired; - Q_EMIT pairingFailed(i18n("Canceled by other peer")); - break; - case PairState::Paired: - m_pairState = PairState::NotPaired; - Q_EMIT unpaired(); - break; + case PairState::NotPaired: + qCDebug(KDECONNECT_CORE) << "Ignoring unpair request for already unpaired device"; + break; + case PairState::Requested: // We started pairing and got rejected + case PairState::RequestedByPeer: // They stared pairing, then cancelled + m_pairState = PairState::NotPaired; + Q_EMIT pairingFailed(i18n("Canceled by other peer")); + break; + case PairState::Paired: + m_pairState = PairState::NotPaired; + Q_EMIT unpaired(); + break; } } } @@ -140,7 +140,8 @@ void PairingHandler::pairingTimeout() Q_EMIT pairingFailed(i18n("Timed out")); } -void PairingHandler::pairingDone() { +void PairingHandler::pairingDone() +{ qCDebug(KDECONNECT_CORE) << "Pairing done"; m_pairState = PairState::Paired; Q_EMIT pairingSuccessful(); diff --git a/core/backends/pairinghandler.h b/core/backends/pairinghandler.h index bc3773479..79deb3c18 100644 --- a/core/backends/pairinghandler.h +++ b/core/backends/pairinghandler.h @@ -24,7 +24,10 @@ public: void packetReceived(const NetworkPacket &np); - PairState pairState() { return m_pairState; } + PairState pairState() + { + return m_pairState; + } public Q_SLOTS: bool requestPairing(); @@ -38,7 +41,6 @@ Q_SIGNALS: void pairingSuccessful(); void unpaired(); - private: void pairingDone(); @@ -48,7 +50,6 @@ private: private Q_SLOTS: void pairingTimeout(); - }; #endif // KDECONNECT_PAIRINGHANDLER_H diff --git a/core/daemon.cpp b/core/daemon.cpp index 9fdb8f1bf..6bd49e75d 100644 --- a/core/daemon.cpp +++ b/core/daemon.cpp @@ -108,7 +108,6 @@ void Daemon::removeDevice(Device *device) Q_EMIT deviceListChanged(); } - void Daemon::forceOnNetworkChange() { qCDebug(KDECONNECT_CORE) << "Sending onNetworkChange to" << d->m_linkProviders.size() << "LinkProviders"; diff --git a/core/device.cpp b/core/device.cpp index 307a41687..b6fba83a1 100644 --- a/core/device.cpp +++ b/core/device.cpp @@ -50,7 +50,7 @@ public: QMultiMap m_pluginsByIncomingCapability; QSet m_supportedPlugins; - PairingHandler* m_pairingHandler; + PairingHandler *m_pairingHandler; }; static void warn(const QString &info) @@ -387,7 +387,6 @@ bool Device::isPairRequested() const return d->m_pairingHandler->pairState() == PairState::Requested; } - bool Device::isPairRequestedByPeer() const { return d->m_pairingHandler->pairState() == PairState::RequestedByPeer; diff --git a/core/filetransferjob.cpp b/core/filetransferjob.cpp index 82aa31a81..85d047b00 100644 --- a/core/filetransferjob.cpp +++ b/core/filetransferjob.cpp @@ -11,11 +11,11 @@ #include #include -#include #include +#include -#include #include +#include FileTransferJob::FileTransferJob(const NetworkPacket *np, const QUrl &destination) : KJob() diff --git a/core/pairstate.h b/core/pairstate.h index eeb1a76d8..08d53c833 100644 --- a/core/pairstate.h +++ b/core/pairstate.h @@ -4,7 +4,6 @@ * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL */ - #ifndef PAIR_STATE_H #define PAIR_STATE_H diff --git a/core/pluginloader.cpp b/core/pluginloader.cpp index 55ed95af0..c9087834d 100644 --- a/core/pluginloader.cpp +++ b/core/pluginloader.cpp @@ -13,9 +13,9 @@ #include #include -#include "kdeconnectconfig.h" #include "core_debug.h" #include "device.h" +#include "kdeconnectconfig.h" #include "kdeconnectplugin.h" // In older Qt released, qAsConst isnt available @@ -124,12 +124,13 @@ QSet PluginLoader::pluginsForCapabilities(const QSet &incoming QString myDeviceType = KdeConnectConfig::instance().deviceType().toString(); for (const KPluginMetaData &service : qAsConst(plugins)) { - // Check if the plugin support this device type - const QSet supportedDeviceTypes = KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-SupportedDeviceTypes")).toSet(); + const QSet supportedDeviceTypes = + KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-SupportedDeviceTypes")).toSet(); if (!supportedDeviceTypes.isEmpty()) { if (!supportedDeviceTypes.contains(myDeviceType)) { - qCDebug(KDECONNECT_CORE) << "Not loading plugin" << service.pluginId() << "because this device of type" << myDeviceType << "is not supported. Supports:" << supportedDeviceTypes.toList().join(QStringLiteral(", ")); + qCDebug(KDECONNECT_CORE) << "Not loading plugin" << service.pluginId() << "because this device of type" << myDeviceType + << "is not supported. Supports:" << supportedDeviceTypes.toList().join(QStringLiteral(", ")); continue; } } @@ -142,15 +143,15 @@ QSet PluginLoader::pluginsForCapabilities(const QSet &incoming bool capabilitiesEmpty = (pluginIncomingCapabilities.isEmpty() && pluginOutgoingCapabilities.isEmpty()); if (!capabilitiesEmpty) { - #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) +#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) bool capabilitiesIntersect = (outgoing.intersects(pluginIncomingCapabilities) || incoming.intersects(pluginOutgoingCapabilities)); - #else +#else QSet commonIncoming = incoming; commonIncoming.intersect(pluginOutgoingCapabilities); QSet commonOutgoing = outgoing; commonOutgoing.intersect(pluginIncomingCapabilities); bool capabilitiesIntersect = (!commonIncoming.isEmpty() || !commonOutgoing.isEmpty()); - #endif +#endif if (!capabilitiesIntersect) { qCDebug(KDECONNECT_CORE) << "Not loading plugin" << service.pluginId() << "because device doesn't support it"; @@ -160,7 +161,6 @@ QSet PluginLoader::pluginsForCapabilities(const QSet &incoming // If we get here, the plugin can be loaded ret += service.pluginId(); - } return ret; diff --git a/daemon/kdeconnectd.cpp b/daemon/kdeconnectd.cpp index d216098c5..093c26171 100644 --- a/daemon/kdeconnectd.cpp +++ b/daemon/kdeconnectd.cpp @@ -20,10 +20,10 @@ #include #include +#include #include #include #include -#include #include diff --git a/indicator/indicatorhelper_win.cpp b/indicator/indicatorhelper_win.cpp index bdf832a15..18de3a81c 100644 --- a/indicator/indicatorhelper_win.cpp +++ b/indicator/indicatorhelper_win.cpp @@ -7,16 +7,16 @@ #include #include #include -#include #include +#include #include #include #include -#include #include +#include #include "indicator_debug.h" #include "indicatorhelper.h" @@ -70,9 +70,11 @@ void onThemeChanged(QSystemTrayIcon &systray) QSettings registry(QStringLiteral("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"), QSettings::Registry64Format); bool isLightTheme = registry.value(QStringLiteral("SystemUsesLightTheme")).toBool(); if (isLightTheme) { - systray.setIcon(QIcon(QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, QStringLiteral("icons/hicolor/scalable/apps/kdeconnectindicator.svg")))); + systray.setIcon( + QIcon(QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, QStringLiteral("icons/hicolor/scalable/apps/kdeconnectindicator.svg")))); } else { - systray.setIcon(QIcon(QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, QStringLiteral("icons/hicolor/scalable/apps/kdeconnectindicatordark.svg")))); + systray.setIcon( + QIcon(QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, QStringLiteral("icons/hicolor/scalable/apps/kdeconnectindicatordark.svg")))); } } diff --git a/interfaces/dbusinterfaces.cpp b/interfaces/dbusinterfaces.cpp index de94216ec..a25ecf409 100644 --- a/interfaces/dbusinterfaces.cpp +++ b/interfaces/dbusinterfaces.cpp @@ -226,15 +226,21 @@ ShareDbusInterface::ShareDbusInterface(const QString &deviceId, QObject *parent) ShareDbusInterface::~ShareDbusInterface() = default; -PhotoDbusInterface::PhotoDbusInterface(const QString& deviceId, QObject* parent): - OrgKdeKdeconnectDevicePhotoInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/photo"), QDBusConnection::sessionBus(), parent) +PhotoDbusInterface::PhotoDbusInterface(const QString &deviceId, QObject *parent) + : OrgKdeKdeconnectDevicePhotoInterface(DaemonDbusInterface::activatedService(), + QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/photo"), + QDBusConnection::sessionBus(), + parent) { } PhotoDbusInterface::~PhotoDbusInterface() = default; -RemoteSystemVolumeDbusInterface::RemoteSystemVolumeDbusInterface(const QString& deviceId, QObject* parent): - OrgKdeKdeconnectDeviceRemotesystemvolumeInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/remotesystemvolume"), QDBusConnection::sessionBus(), parent) +RemoteSystemVolumeDbusInterface::RemoteSystemVolumeDbusInterface(const QString &deviceId, QObject *parent) + : OrgKdeKdeconnectDeviceRemotesystemvolumeInterface(DaemonDbusInterface::activatedService(), + QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/remotesystemvolume"), + QDBusConnection::sessionBus(), + parent) { } diff --git a/interfaces/dbusinterfaces.h b/interfaces/dbusinterfaces.h index 931cdf1c4..8f783134c 100644 --- a/interfaces/dbusinterfaces.h +++ b/interfaces/dbusinterfaces.h @@ -231,17 +231,15 @@ public: ~ShareDbusInterface() override; }; -class KDECONNECTINTERFACES_EXPORT PhotoDbusInterface - : public OrgKdeKdeconnectDevicePhotoInterface +class KDECONNECTINTERFACES_EXPORT PhotoDbusInterface : public OrgKdeKdeconnectDevicePhotoInterface { Q_OBJECT public: - explicit PhotoDbusInterface(const QString& deviceId, QObject* parent = nullptr); + explicit PhotoDbusInterface(const QString &deviceId, QObject *parent = nullptr); ~PhotoDbusInterface() override; }; -class KDECONNECTINTERFACES_EXPORT RemoteSystemVolumeDbusInterface - : public OrgKdeKdeconnectDeviceRemotesystemvolumeInterface +class KDECONNECTINTERFACES_EXPORT RemoteSystemVolumeDbusInterface : public OrgKdeKdeconnectDeviceRemotesystemvolumeInterface { Q_OBJECT public: diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp index 0311c08bb..d58bbb73f 100644 --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -278,7 +278,6 @@ void KdeConnectKcm::pairingFailed(const QString &error) kcmUi->messages->animatedShow(); } - void KdeConnectKcm::setCurrentDevicePairState(int pairStateAsInt) { PairState state = (PairState)pairStateAsInt; // Hack because qdbus doesn't like enums diff --git a/kcm/kcm.h b/kcm/kcm.h index d85a68bfa..4a459b6ba 100644 --- a/kcm/kcm.h +++ b/kcm/kcm.h @@ -51,7 +51,6 @@ private Q_SLOTS: void acceptPairing(); void cancelPairing(); - private: void resetDeviceView(); diff --git a/plugins/clipboard/clipboard_config.cpp b/plugins/clipboard/clipboard_config.cpp index 080a067b6..2fd9f4fe7 100644 --- a/plugins/clipboard/clipboard_config.cpp +++ b/plugins/clipboard/clipboard_config.cpp @@ -11,7 +11,7 @@ K_PLUGIN_FACTORY(ClipboardConfigFactory, registerPlugin();) -ClipboardConfig::ClipboardConfig(QWidget* parent, const QVariantList &args) +ClipboardConfig::ClipboardConfig(QWidget *parent, const QVariantList &args) : KdeConnectPluginKcm(parent, args, QStringLiteral("kdeconnect_clipboard")) , m_ui(new Ui::ClipboardConfigUi()) { diff --git a/plugins/clipboard/clipboard_config.h b/plugins/clipboard/clipboard_config.h index 34179600a..626ece4d2 100644 --- a/plugins/clipboard/clipboard_config.h +++ b/plugins/clipboard/clipboard_config.h @@ -9,16 +9,16 @@ #include "kcmplugin/kdeconnectpluginkcm.h" -namespace Ui { - class ClipboardConfigUi; +namespace Ui +{ +class ClipboardConfigUi; } -class ClipboardConfig - : public KdeConnectPluginKcm +class ClipboardConfig : public KdeConnectPluginKcm { Q_OBJECT public: - ClipboardConfig(QWidget *parent, const QVariantList&); + ClipboardConfig(QWidget *parent, const QVariantList &); ~ClipboardConfig() override; public Q_SLOTS: @@ -29,7 +29,6 @@ public Q_SLOTS: private: Ui::ClipboardConfigUi *m_ui; - }; #endif diff --git a/plugins/notifications/notification.cpp b/plugins/notifications/notification.cpp index 6e0891cbc..61cca8333 100644 --- a/plugins/notifications/notification.cpp +++ b/plugins/notifications/notification.cpp @@ -187,12 +187,12 @@ void Notification::reply() Q_EMIT replyRequested(); } -void Notification::sendReply(const QString& message) +void Notification::sendReply(const QString &message) { Q_EMIT replied(message); } -void Notification::parseNetworkPacket(const NetworkPacket& np) +void Notification::parseNetworkPacket(const NetworkPacket &np) { m_internalId = np.get(QStringLiteral("id")); m_appName = np.get(QStringLiteral("appName")); diff --git a/plugins/notifications/notification.h b/plugins/notifications/notification.h index cda88c8f1..e64a0c640 100644 --- a/plugins/notifications/notification.h +++ b/plugins/notifications/notification.h @@ -86,7 +86,7 @@ public: public Q_SLOTS: Q_SCRIPTABLE void dismiss(); Q_SCRIPTABLE void reply(); - Q_SCRIPTABLE void sendReply(const QString& message); + Q_SCRIPTABLE void sendReply(const QString &message); Q_SIGNALS: void dismissRequested(const QString &m_internalId); diff --git a/plugins/remotekeyboard/remotekeyboardplugin.cpp b/plugins/remotekeyboard/remotekeyboardplugin.cpp index f8ad748c5..1985efccf 100644 --- a/plugins/remotekeyboard/remotekeyboardplugin.cpp +++ b/plugins/remotekeyboard/remotekeyboardplugin.cpp @@ -117,12 +117,7 @@ void RemoteKeyboardPlugin::sendQKeyEvent(const QVariantMap &keyEvent, bool sendA text = QKeySequence(key).toString().toLower(); } - sendKeyPress(text, - k, - modifiers & Qt::ShiftModifier, - modifiers & Qt::ControlModifier, - modifiers & Qt::AltModifier, - sendAck); + sendKeyPress(text, k, modifiers & Qt::ShiftModifier, modifiers & Qt::ControlModifier, modifiers & Qt::AltModifier, sendAck); } int RemoteKeyboardPlugin::translateQtKey(int qtKey) const diff --git a/plugins/runcommand/runcommand_config.cpp b/plugins/runcommand/runcommand_config.cpp index fc5138361..9b102633b 100644 --- a/plugins/runcommand/runcommand_config.cpp +++ b/plugins/runcommand/runcommand_config.cpp @@ -7,11 +7,11 @@ #include "runcommand_config.h" #include +#include #include #include -#include #include -#include +#include #include #include #include diff --git a/plugins/sendnotifications/notifyingapplicationmodel.cpp b/plugins/sendnotifications/notifyingapplicationmodel.cpp index a096d9199..e4d4758d1 100644 --- a/plugins/sendnotifications/notifyingapplicationmodel.cpp +++ b/plugins/sendnotifications/notifyingapplicationmodel.cpp @@ -14,7 +14,7 @@ #include -//#include "modeltest.h" +// #include "modeltest.h" NotifyingApplicationModel::NotifyingApplicationModel(QObject *parent) : QAbstractTableModel(parent) diff --git a/plugins/systemvolume/systemvolumeplugin-win.cpp b/plugins/systemvolume/systemvolumeplugin-win.cpp index 19634e8b5..db8f0c675 100644 --- a/plugins/systemvolume/systemvolumeplugin-win.cpp +++ b/plugins/systemvolume/systemvolumeplugin-win.cpp @@ -445,7 +445,6 @@ bool SystemvolumePlugin::receivePacket(const NetworkPacket &np) setDefaultAudioPlaybackDevice(name, np.get(QStringLiteral("enabled"))); } } - } } return true;