kdeconnect-kde/plugins/contacts/contactsplugin.cpp

194 lines
6.6 KiB
C++
Raw Permalink Normal View History

Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
/**
* SPDX-FileCopyrightText: 2018 Simon Redman <simon@ergotech.com>
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
*/
#include <contactsplugin.h>
#include <KPluginFactory>
#include <QDBusConnection>
2019-02-03 00:44:22 +00:00
#include <QDBusMetaType>
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
#include <QDir>
#include <QFile>
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
#include <QIODevice>
#include <core/device.h>
#include "plugin_contacts_debug.h"
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
K_PLUGIN_CLASS_WITH_JSON(ContactsPlugin, "kdeconnect_contacts.json")
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
ContactsPlugin::ContactsPlugin(QObject *parent, const QVariantList &args)
: KdeConnectPlugin(parent, args)
, vcardsPath(QString(*vcardsLocation).append(QStringLiteral("/kdeconnect-").append(device()->id())))
(WIP) Upgrade Telephony plugin to read SMS history (KDE side) Summary: For real usecases of SMS support, we will almost always need access to the message history in some way Specifically resolve T8338 Incidentally resolve T6651 since Telephony shall no longer create a notification Test Plan: Setup: - Build corresponding Android-side diff (D11698) - Build this diff Step 1: Does anything at all work? - Put a breakpoint in the handleBatchMessages method of the telephony plugin, ideally after constructing a Message object - Use DBus to poke /modules/kdeconnect/devices/<deviceID>/telephony.requestAllConversations() - Verify that the constructed Message is one you sent or received and that it is the most recent in the corresponding conversation Step 2: DBus - Open the Interface org.kde.kdeconnect.device.conversations of /modules/kdeconnect/devices/<deviceId> - Poke activeConversations and verify an empty array is returned - Poke requestAllConversationThreads - Poke activeConversations and verify that a list of numbers has been returned. These are conversationIds - Use a conversationId to call getFirstFromConversation - Verify that the returned Message object is one which you recognize - Note that if the message is an MMS it will be blank and meaningless. Try a different conversationId. MMS support "coming soon!" Step 3: SMS App - Use ccmake (or similar) to set SMSAPP_ENABLE to ON - Build the project - Run ./bin/kdeconnect-sms - Verify that the app shows a list of everyone you have an SMS conversation with (MMS messages are stripped out) - If you have the Contacts plugin working, verify that most contacts have their name and photo instead of their phone number Reviewers: #kde_connect, nicolasfella, apol Reviewed By: #kde_connect, nicolasfella, apol Subscribers: andyholmes, apol, nicolasfella, #kde_connect Tags: #kde_connect Maniphest Tasks: T8338, T6651 Differential Revision: https://phabricator.kde.org/D11854
2018-05-25 15:21:56 +01:00
{
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
// Register custom types with dbus
qRegisterMetaType<uID>("uID");
qDBusRegisterMetaType<uID>();
qRegisterMetaType<uIDList_t>("uIDList_t");
qDBusRegisterMetaType<uIDList_t>();
// Create the storage directory if it doesn't exist
if (!QDir().mkpath(vcardsPath)) {
qCWarning(KDECONNECT_PLUGIN_CONTACTS) << "Unable to create VCard directory";
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
}
qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "Contacts constructor for device " << device()->name();
}
void ContactsPlugin::connected()
{
synchronizeRemoteWithLocal();
}
void ContactsPlugin::receivePacket(const NetworkPacket &np)
{
// qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "Packet Received for device " << device()->name();
// qCDebug(KDECONNECT_PLUGIN_CONTACTS) << np.body();
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
if (np.type() == PACKAGE_TYPE_CONTACTS_RESPONSE_UIDS_TIMESTAMPS) {
handleResponseUIDsTimestamps(np);
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
} else if (np.type() == PACKET_TYPE_CONTACTS_RESPONSE_VCARDS) {
handleResponseVCards(np);
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
}
}
void ContactsPlugin::synchronizeRemoteWithLocal()
{
2019-05-04 15:15:49 +01:00
sendRequest(PACKET_TYPE_CONTACTS_REQUEST_ALL_UIDS_TIMESTAMP);
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
}
bool ContactsPlugin::handleResponseUIDsTimestamps(const NetworkPacket &np)
{
if (!np.has(QStringLiteral("uids"))) {
2024-06-04 18:02:58 +01:00
qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "handleResponseUIDsTimestamps:"
<< "Malformed packet does not have uids key";
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
return false;
}
uIDList_t uIDsToUpdate;
QDir vcardsDir(vcardsPath);
// Get a list of all file info in this directory
// Clean out IDs returned from the remote. Anything leftover should be deleted
QFileInfoList localVCards = vcardsDir.entryInfoList({QStringLiteral("*.vcard"), QStringLiteral("*.vcf")});
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
const QStringList &uIDs = np.get<QStringList>(QStringLiteral("uids"));
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
// Check local storage for the contacts:
// If the contact is not found in local storage, request its vcard be sent
// If the contact is in local storage but not reported, delete it
// If the contact is in local storage, compare its timestamp. If different, request the contact
for (const QString &ID : uIDs) {
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
QString filename = vcardsDir.filePath(ID + VCARD_EXTENSION);
QFile vcardFile(filename);
if (!QFile().exists(filename)) {
// We do not have a vcard for this contact. Request it.
uIDsToUpdate.push_back(ID);
continue;
}
// Remove this file from the list of known files
QFileInfo fileInfo(vcardFile);
localVCards.removeOne(fileInfo);
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
// Check if the vcard needs to be updated
if (!vcardFile.open(QIODevice::ReadOnly)) {
2024-06-04 18:02:58 +01:00
qCWarning(KDECONNECT_PLUGIN_CONTACTS) << "handleResponseUIDsTimestamps:"
<< "Unable to open" << filename << "to read even though it was reported to exist";
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
continue;
}
QTextStream fileReadStream(&vcardFile);
QString line;
while (!fileReadStream.atEnd()) {
fileReadStream >> line;
// TODO: Check that the saved ID is the same as the one we were expecting. This requires parsing the VCard
if (!line.startsWith(QStringLiteral("X-KDECONNECT-TIMESTAMP:"))) {
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
continue;
}
2019-02-03 00:30:18 +00:00
QStringList parts = line.split(QLatin1Char(':'));
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
QString timestamp = parts[1];
qint64 remoteTimestamp = np.get<qint64>(ID);
qint64 localTimestamp = timestamp.toLongLong();
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
if (!(localTimestamp == remoteTimestamp)) {
uIDsToUpdate.push_back(ID);
}
}
}
// Delete all locally-known files which were not reported by the remote device
for (const QFileInfo &unknownFile : localVCards) {
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
QFile toDelete(unknownFile.filePath());
toDelete.remove();
}
2019-05-04 15:15:49 +01:00
sendRequestWithIDs(PACKET_TYPE_CONTACTS_REQUEST_VCARDS_BY_UIDS, uIDsToUpdate);
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
return true;
}
bool ContactsPlugin::handleResponseVCards(const NetworkPacket &np)
{
if (!np.has(QStringLiteral("uids"))) {
2024-06-04 18:02:58 +01:00
qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "handleResponseVCards:"
<< "Malformed packet does not have uids key";
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
return false;
}
QDir vcardsDir(vcardsPath);
const QStringList &uIDs = np.get<QStringList>(QStringLiteral("uids"));
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
// Loop over all IDs, extract the VCard from the packet and write the file
for (const auto &ID : uIDs) {
// qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "Got VCard:" << np.get<QString>(ID);
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
QString filename = vcardsDir.filePath(ID + VCARD_EXTENSION);
QFile vcardFile(filename);
bool vcardFileOpened = vcardFile.open(QIODevice::WriteOnly); // Want to smash anything that might have already been there
if (!vcardFileOpened) {
2024-06-04 18:02:58 +01:00
qCWarning(KDECONNECT_PLUGIN_CONTACTS) << "handleResponseVCards:"
<< "Unable to open" << filename;
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
continue;
}
QTextStream fileWriteStream(&vcardFile);
const QString &vcard = np.get<QString>(ID);
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
fileWriteStream << vcard;
}
2024-06-04 18:02:58 +01:00
qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "handleResponseVCards:"
<< "Got" << uIDs.size() << "VCards";
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
Q_EMIT localCacheSynchronized(uIDs);
return true;
}
bool ContactsPlugin::sendRequest(const QString &packetType)
{
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
NetworkPacket np(packetType);
bool success = sendPacket(np);
qCDebug(KDECONNECT_PLUGIN_CONTACTS) << "sendRequest: Sending " << packetType << success;
return success;
}
bool ContactsPlugin::sendRequestWithIDs(const QString &packetType, const uIDList_t &uIDs)
{
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
NetworkPacket np(packetType);
np.set<uIDList_t>(QStringLiteral("uids"), uIDs);
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
bool success = sendPacket(np);
return success;
}
QString ContactsPlugin::dbusPath() const
{
return QLatin1String("/modules/kdeconnect/devices/%1/contacts").arg(device()->id());
Add contacts-reading plugin (KDE side) Summary: Add a plugin to KDE Connect which supports exporting the Android contacts databases to vcards on the desktop When the devices are connected, the plugin sends a request for all timestamps and IDs When a packet with timestamps and IDs is received, it verifies it has vcards for each ID and that the timestamps match and deletes any vcards for IDs which were not reported. It then sends a request for all vcards which were missing or need updating When a packet with vcards is received they are unconditionally written to disk, possibly overwriting existing vcards Provides one dbus method: contacts/synchronizeRemoteWithLocal which triggers the request for all timestamps and IDs BUG: 367999 Test Plan: Connect the device to the desktop and verify that vcards are created in QStandardPaths::GenericDataLocation / kpeoplevcard". On my system this is ~/.local/share/kpeoplevcard Create a dummy contact on the device and verify it is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Modify the dummy contact and verify the modifications are synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Delete the dummy contact and verify the deletion is synchronized (Currently not automatic, have to disconnect and reconnect or use dbus) Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: mtijink, #kde_connect, apol Tags: #kde_connect Maniphest Tasks: T8283 Differential Revision: https://phabricator.kde.org/D9691
2018-04-23 21:27:38 +01:00
}
#include "contactsplugin.moc"
#include "moc_contactsplugin.cpp"