[plugins/contacts] Unify coding style

This commit is contained in:
Nicolas Fella 2019-05-04 16:15:49 +02:00
parent aff3d20e7e
commit 137d504b58
2 changed files with 23 additions and 25 deletions

View file

@ -36,7 +36,7 @@ K_PLUGIN_FACTORY_WITH_JSON(KdeConnectPluginFactory, "kdeconnect_contacts.json",
Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_CONTACTS, "kdeconnect.plugin.contacts") 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) KdeConnectPlugin(parent, args)
{ {
vcardsPath = QString(*vcardsLocation).append("/kdeconnect-").append(device()->id()); 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"; qCWarning(KDECONNECT_PLUGIN_CONTACTS) << "handleResponseVCards:" << "Unable to create VCard directory";
} }
this->synchronizeRemoteWithLocal(); synchronizeRemoteWithLocal();
qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "Contacts constructor for device " << device()->name(); qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "Contacts constructor for device " << device()->name();
} }
ContactsPlugin::~ContactsPlugin () { ContactsPlugin::~ContactsPlugin() {
QDBusConnection::sessionBus().unregisterObject(dbusPath(), QDBusConnection::UnregisterTree); QDBusConnection::sessionBus().unregisterObject(dbusPath(), QDBusConnection::UnregisterTree);
// qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "Contacts plugin destructor for device" << device()->name(); // 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) << "Packet Received for device " << device()->name();
//qCDebug(KDECONNECT_PLUGIN_CONTACTS) << np.body(); //qCDebug(KDECONNECT_PLUGIN_CONTACTS) << np.body();
if (np.type() == PACKAGE_TYPE_CONTACTS_RESPONSE_UIDS_TIMESTAMPS) { 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) { } else if (np.type() == PACKET_TYPE_CONTACTS_RESPONSE_VCARDS) {
return this->handleResponseVCards(np); return handleResponseVCards(np);
} else { } else {
// Is this check necessary? // Is this check necessary?
qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "Unknown package type received from device: " qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "Unknown package type received from device: "
@ -79,11 +79,11 @@ bool ContactsPlugin::receivePacket (const NetworkPacket& np) {
} }
} }
void ContactsPlugin::synchronizeRemoteWithLocal () { void ContactsPlugin::synchronizeRemoteWithLocal() {
this->sendRequest(PACKET_TYPE_CONTACTS_REQUEST_ALL_UIDS_TIMESTAMP); sendRequest(PACKET_TYPE_CONTACTS_REQUEST_ALL_UIDS_TIMESTAMP);
} }
bool ContactsPlugin::handleResponseUIDsTimestamps (const NetworkPacket& np) { bool ContactsPlugin::handleResponseUIDsTimestamps(const NetworkPacket& np) {
if (!np.has("uids")) { if (!np.has("uids")) {
qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "handleResponseUIDsTimestamps:" qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "handleResponseUIDsTimestamps:"
<< "Malformed packet does not have uids key"; << "Malformed packet does not have uids key";
@ -150,12 +150,12 @@ bool ContactsPlugin::handleResponseUIDsTimestamps (const NetworkPacket& np) {
toDelete.remove(); toDelete.remove();
} }
this->sendRequestWithIDs(PACKET_TYPE_CONTACTS_REQUEST_VCARDS_BY_UIDS, uIDsToUpdate); sendRequestWithIDs(PACKET_TYPE_CONTACTS_REQUEST_VCARDS_BY_UIDS, uIDsToUpdate);
return true; return true;
} }
bool ContactsPlugin::handleResponseVCards (const NetworkPacket& np) { bool ContactsPlugin::handleResponseVCards(const NetworkPacket& np) {
if (!np.has("uids")) { if (!np.has("uids")) {
qCDebug(KDECONNECT_PLUGIN_CONTACTS) qCDebug(KDECONNECT_PLUGIN_CONTACTS)
<< "handleResponseVCards:" << "Malformed packet does not have uids key"; << "handleResponseVCards:" << "Malformed packet does not have uids key";
@ -185,7 +185,7 @@ bool ContactsPlugin::handleResponseVCards (const NetworkPacket& np) {
return true; return true;
} }
bool ContactsPlugin::sendRequest (const QString& packetType) { bool ContactsPlugin::sendRequest(const QString& packetType) {
NetworkPacket np(packetType); NetworkPacket np(packetType);
bool success = sendPacket(np); bool success = sendPacket(np);
qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "sendRequest: Sending " << packetType << success; qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "sendRequest: Sending " << packetType << success;
@ -193,7 +193,7 @@ bool ContactsPlugin::sendRequest (const QString& packetType) {
return success; 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); NetworkPacket np(packetType);
np.set<uIDList_t>("uids", uIDs); np.set<uIDList_t>("uids", uIDs);
@ -201,7 +201,7 @@ bool ContactsPlugin::sendRequestWithIDs (const QString& packetType, const uIDLis
return success; return success;
} }
QString ContactsPlugin::dbusPath () const { QString ContactsPlugin::dbusPath() const {
return "/modules/kdeconnect/devices/" + device()->id() + "/contacts"; return "/modules/kdeconnect/devices/" + device()->id() + "/contacts";
} }

View file

@ -90,11 +90,11 @@ class Q_DECL_EXPORT ContactsPlugin : public KdeConnectPlugin {
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.contacts") Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.contacts")
public: public:
explicit ContactsPlugin (QObject *parent, const QVariantList &args); explicit ContactsPlugin(QObject* parent, const QVariantList& args);
~ContactsPlugin () override; ~ContactsPlugin () override;
bool receivePacket (const NetworkPacket& np) override; bool receivePacket(const NetworkPacket& np) override;
void connected () override { void connected() override {
} }
QString dbusPath () const override; QString dbusPath () const override;
@ -113,8 +113,7 @@ public Q_SLOTS:
* Update any contacts which are known locally but have an older timestamp * 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 * Add any contacts which are not known locally but are reported by the remote
*/ */
Q_SCRIPTABLE Q_SCRIPTABLE void synchronizeRemoteWithLocal();
void synchronizeRemoteWithLocal ();
public: public:
Q_SIGNALS: Q_SIGNALS:
@ -123,8 +122,7 @@ Q_SIGNALS:
* *
* @param newContacts The list of just-synchronized contacts * @param newContacts The list of just-synchronized contacts
*/ */
Q_SCRIPTABLE Q_SCRIPTABLE void localCacheSynchronized(const uIDList_t& newContacts);
void localCacheSynchronized (const uIDList_t& newContacts);
protected: protected:
@ -136,19 +134,19 @@ protected:
* Compare the modified timestamp for each in the reply and update any which should have changed * 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 * 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 * 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 * Send a request-type packet which contains no body
* *
* @return True if the send was successful, false otherwise * @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 * 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 * @param uIDs List of uIDs to request
* @return True if the send was successful, false otherwise * @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 #endif // CONTACTSPLUGIN_H