Commit 137d504b authored by Nicolas Fella's avatar Nicolas Fella
Browse files

[plugins/contacts] Unify coding style

parent aff3d20e
Pipeline #3071 failed with stage
in 6 minutes and 24 seconds
......@@ -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<uIDList_t>("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";
}
......
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment