From 137d504b58c78495facb6c2b701aca7039b27440 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Sat, 4 May 2019 16:15:49 +0200 Subject: [PATCH] [plugins/contacts] Unify coding style --- plugins/contacts/contactsplugin.cpp | 28 ++++++++++++++-------------- plugins/contacts/contactsplugin.h | 20 +++++++++----------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/plugins/contacts/contactsplugin.cpp b/plugins/contacts/contactsplugin.cpp index de3368ef7..73646169a 100644 --- a/plugins/contacts/contactsplugin.cpp +++ b/plugins/contacts/contactsplugin.cpp @@ -36,7 +36,7 @@ K_PLUGIN_FACTORY_WITH_JSON(KdeConnectPluginFactory, "kdeconnect_contacts.json", Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_CONTACTS, "kdeconnect.plugin.contacts") -ContactsPlugin::ContactsPlugin (QObject* parent, const QVariantList& args) : +ContactsPlugin::ContactsPlugin(QObject* parent, const QVariantList& args) : KdeConnectPlugin(parent, args) { vcardsPath = QString(*vcardsLocation).append("/kdeconnect-").append(device()->id()); @@ -53,24 +53,24 @@ ContactsPlugin::ContactsPlugin (QObject* parent, const QVariantList& args) : qCWarning(KDECONNECT_PLUGIN_CONTACTS) << "handleResponseVCards:" << "Unable to create VCard directory"; } - this->synchronizeRemoteWithLocal(); + synchronizeRemoteWithLocal(); qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "Contacts constructor for device " << device()->name(); } -ContactsPlugin::~ContactsPlugin () { +ContactsPlugin::~ContactsPlugin() { QDBusConnection::sessionBus().unregisterObject(dbusPath(), QDBusConnection::UnregisterTree); // qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "Contacts plugin destructor for device" << device()->name(); } -bool ContactsPlugin::receivePacket (const NetworkPacket& np) { +bool ContactsPlugin::receivePacket(const NetworkPacket& np) { //qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "Packet Received for device " << device()->name(); //qCDebug(KDECONNECT_PLUGIN_CONTACTS) << np.body(); if (np.type() == PACKAGE_TYPE_CONTACTS_RESPONSE_UIDS_TIMESTAMPS) { - return this->handleResponseUIDsTimestamps(np); + return handleResponseUIDsTimestamps(np); } else if (np.type() == PACKET_TYPE_CONTACTS_RESPONSE_VCARDS) { - return this->handleResponseVCards(np); + return handleResponseVCards(np); } else { // Is this check necessary? qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "Unknown package type received from device: " @@ -79,11 +79,11 @@ bool ContactsPlugin::receivePacket (const NetworkPacket& np) { } } -void ContactsPlugin::synchronizeRemoteWithLocal () { - this->sendRequest(PACKET_TYPE_CONTACTS_REQUEST_ALL_UIDS_TIMESTAMP); +void ContactsPlugin::synchronizeRemoteWithLocal() { + sendRequest(PACKET_TYPE_CONTACTS_REQUEST_ALL_UIDS_TIMESTAMP); } -bool ContactsPlugin::handleResponseUIDsTimestamps (const NetworkPacket& np) { +bool ContactsPlugin::handleResponseUIDsTimestamps(const NetworkPacket& np) { if (!np.has("uids")) { qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "handleResponseUIDsTimestamps:" << "Malformed packet does not have uids key"; @@ -150,12 +150,12 @@ bool ContactsPlugin::handleResponseUIDsTimestamps (const NetworkPacket& np) { toDelete.remove(); } - this->sendRequestWithIDs(PACKET_TYPE_CONTACTS_REQUEST_VCARDS_BY_UIDS, uIDsToUpdate); + sendRequestWithIDs(PACKET_TYPE_CONTACTS_REQUEST_VCARDS_BY_UIDS, uIDsToUpdate); return true; } -bool ContactsPlugin::handleResponseVCards (const NetworkPacket& np) { +bool ContactsPlugin::handleResponseVCards(const NetworkPacket& np) { if (!np.has("uids")) { qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "handleResponseVCards:" << "Malformed packet does not have uids key"; @@ -185,7 +185,7 @@ bool ContactsPlugin::handleResponseVCards (const NetworkPacket& np) { return true; } -bool ContactsPlugin::sendRequest (const QString& packetType) { +bool ContactsPlugin::sendRequest(const QString& packetType) { NetworkPacket np(packetType); bool success = sendPacket(np); qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "sendRequest: Sending " << packetType << success; @@ -193,7 +193,7 @@ bool ContactsPlugin::sendRequest (const QString& packetType) { return success; } -bool ContactsPlugin::sendRequestWithIDs (const QString& packetType, const uIDList_t& uIDs) { +bool ContactsPlugin::sendRequestWithIDs(const QString& packetType, const uIDList_t& uIDs) { NetworkPacket np(packetType); np.set("uids", uIDs); @@ -201,7 +201,7 @@ bool ContactsPlugin::sendRequestWithIDs (const QString& packetType, const uIDLis return success; } -QString ContactsPlugin::dbusPath () const { +QString ContactsPlugin::dbusPath() const { return "/modules/kdeconnect/devices/" + device()->id() + "/contacts"; } diff --git a/plugins/contacts/contactsplugin.h b/plugins/contacts/contactsplugin.h index d2bdd1f41..e19f1d405 100644 --- a/plugins/contacts/contactsplugin.h +++ b/plugins/contacts/contactsplugin.h @@ -90,11 +90,11 @@ class Q_DECL_EXPORT ContactsPlugin : public KdeConnectPlugin { Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.contacts") public: - explicit ContactsPlugin (QObject *parent, const QVariantList &args); + explicit ContactsPlugin(QObject* parent, const QVariantList& args); ~ContactsPlugin () override; - bool receivePacket (const NetworkPacket& np) override; - void connected () override { + bool receivePacket(const NetworkPacket& np) override; + void connected() override { } QString dbusPath () const override; @@ -113,8 +113,7 @@ public Q_SLOTS: * Update any contacts which are known locally but have an older timestamp * Add any contacts which are not known locally but are reported by the remote */ - Q_SCRIPTABLE - void synchronizeRemoteWithLocal (); + Q_SCRIPTABLE void synchronizeRemoteWithLocal(); public: Q_SIGNALS: @@ -123,8 +122,7 @@ Q_SIGNALS: * * @param newContacts The list of just-synchronized contacts */ - Q_SCRIPTABLE - void localCacheSynchronized (const uIDList_t& newContacts); + Q_SCRIPTABLE void localCacheSynchronized(const uIDList_t& newContacts); protected: @@ -136,19 +134,19 @@ protected: * Compare the modified timestamp for each in the reply and update any which should have changed * Request the details any IDs which were not locally cached */ - bool handleResponseUIDsTimestamps (const NetworkPacket&); + bool handleResponseUIDsTimestamps(const NetworkPacket&); /** * Handle a packet of type PACKET_TYPE_CONTACTS_RESPONSE_VCARDS */ - bool handleResponseVCards (const NetworkPacket&); + bool handleResponseVCards(const NetworkPacket&); /** * Send a request-type packet which contains no body * * @return True if the send was successful, false otherwise */ - bool sendRequest (const QString& packetType); + bool sendRequest(const QString& packetType); /** * Send a request-type packet which has a body with the key 'uids' and the value the list of @@ -158,7 +156,7 @@ protected: * @param uIDs List of uIDs to request * @return True if the send was successful, false otherwise */ - bool sendRequestWithIDs (const QString& packetType, const uIDList_t& uIDs); + bool sendRequestWithIDs(const QString& packetType, const uIDList_t& uIDs); }; #endif // CONTACTSPLUGIN_H