Skip to content

Commit

Permalink
Use current version of KDE Connect
Browse files Browse the repository at this point in the history
  • Loading branch information
R1tschY committed Apr 9, 2024
1 parent b9c64b2 commit 720f59e
Show file tree
Hide file tree
Showing 25 changed files with 51 additions and 81 deletions.
3 changes: 2 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
url = https://github.com/google/googletest
[submodule "kdeconnect/kdeconnect"]
path = kdeconnect-kde
url = https://invent.kde.org/richardliebscher/kdeconnect-kde.git
url = https://invent.kde.org/richardliebscher/kdeconnect-sfos.git
branch = sailfishconnect
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.16)
cmake_policy(SET CMP0071 NEW)
project(SailfishConnect VERSION 0.7.0 LANGUAGES C CXX)

Expand Down
4 changes: 2 additions & 2 deletions app/qml/pages/DevicePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Page {

Button {
text: i18n("Reject")
onClicked: _device.rejectPairing()
onClicked: _device.cancelPairing()
}
}

Expand Down Expand Up @@ -160,7 +160,7 @@ Page {

text: i18n("Connect")
onClicked: {
_device.requestPair()
_device.requestPairing()
}
}

Expand Down
14 changes: 7 additions & 7 deletions app/qml/pages/TouchpadPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ Page {
onClicked: {
if (!wasMoved && plugin !== null) {
if (!holding) {
plugin.sendCommand("singleclick", true)
plugin.sendCommand({"singleclick": true})
} else {
plugin.sendCommand("singlerelease", true)
plugin.sendCommand({"singlerelease": true})
holding = false
}
}
Expand All @@ -164,17 +164,17 @@ Page {
onDoubleClicked: {
if (!wasMoved && plugin !== null) {
if (!holding) {
plugin.sendCommand("doubleclick", true)
plugin.sendCommand({"doubleclick": true})
} else {
plugin.sendCommand("singlerelease", true)
plugin.sendCommand({"singlerelease": true})
holding = false
}
}
}

onPressAndHold: {
if (!wasMoved && plugin !== null) {
plugin.sendCommand("singlehold", true)
plugin.sendCommand({"singlehold": true})
holding = true
}
}
Expand Down Expand Up @@ -204,7 +204,7 @@ Page {
spacing: Theme.paddingSmall

Button {
onClicked: plugin.sendCommand("singleclick", true)
onClicked: plugin.sendCommand({"singleclick": true})
preferredWidth: Theme.buttonWidthExtraSmall
width: parent.btnWidth
}
Expand All @@ -216,7 +216,7 @@ Page {
}

Button {
onClicked: plugin.sendCommand("rightclick", true)
onClicked: plugin.sendCommand({"rightclick": true})
preferredWidth: Theme.buttonWidthExtraSmall
width: parent.btnWidth
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/appdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void AppDaemon::askPairingConfirmation(Device *device)
notification->setBody(i18n("Pending pairing request ..."));
notification->setPreviewSummary(device->name());
notification->setPreviewBody(i18n("Pairing request"));
notification->setExpireTimeout(PairingHandler::pairingTimeoutMsec());
notification->setExpireTimeout(PairingHandler::pairingTimeoutMsec);
notification->setRemoteActions(
{ UI::openDevicePageDbusAction(device->id()) });

Expand Down Expand Up @@ -161,7 +161,7 @@ void AppDaemon::onWakeUp()
void AppDaemon::onDeviceAdded(const QString &deviceId)
{
auto device = this->getDevice(deviceId);
connect(device, &Device::pairingError, this,
connect(device, &Device::pairingFailed, this,
[this, deviceId](const QString& err) {
onPairingError(deviceId, err);
});
Expand Down
12 changes: 6 additions & 6 deletions app/src/dbus/kdeconnect.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class RemoteControlApi : public RemoteControlDbusInterface {
checkForDbusError(RemoteControlDbusInterface::moveCursor(p));
}

Q_SCRIPTABLE void sendCommand(const QString &name, bool val) {
checkForDbusError(RemoteControlDbusInterface::sendCommand(name, val));
Q_SCRIPTABLE void sendCommand(const QVariantMap &body) {
checkForDbusError(RemoteControlDbusInterface::sendCommand(body));
}

Q_SCRIPTABLE void scroll(int x, int y) {
Expand Down Expand Up @@ -140,16 +140,16 @@ class DeviceApi : public DeviceDbusInterface {
checkForDbusError(DeviceDbusInterface::unpair());
}

Q_SCRIPTABLE void requestPair() {
checkForDbusError(DeviceDbusInterface::requestPair());
Q_SCRIPTABLE void requestPairing() {
checkForDbusError(DeviceDbusInterface::requestPairing());
}

Q_SCRIPTABLE void acceptPairing() {
checkForDbusError(DeviceDbusInterface::acceptPairing());
}

Q_SCRIPTABLE void rejectPairing() {
checkForDbusError(DeviceDbusInterface::rejectPairing());
Q_SCRIPTABLE void cancelPairing() {
checkForDbusError(DeviceDbusInterface::cancelPairing());
}

Q_SCRIPTABLE QString encryptionInfo() {
Expand Down
28 changes: 8 additions & 20 deletions app/src/models/devicelistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ DeviceListModel::DeviceListModel(QObject *parent)
{
m_daemon = Daemon::instance();

m_id = QString("DeviceListModel{0x%1}").arg(
reinterpret_cast<std::uintptr_t>(this), 0, 16);
m_daemon->acquireDiscoveryMode(m_id);
m_devices = m_daemon->devicesList();

connect(m_daemon, &Daemon::deviceAdded,
Expand All @@ -65,10 +62,7 @@ DeviceListModel::DeviceListModel(QObject *parent)
}
}

DeviceListModel::~DeviceListModel()
{
m_daemon->releaseDiscoveryMode(m_id);
}
DeviceListModel::~DeviceListModel() = default;

int DeviceListModel::rowCount(const QModelIndex &parent) const
{
Expand All @@ -90,19 +84,19 @@ QVariant DeviceListModel::data(const QModelIndex &index, int role) const
case IdRole:
return device->id();
case IconUrlRole:
return deviceTypeToIcon(device->type());
return deviceTypeToIcon(device->type().toString());
case SectionRole:
return device->isTrusted()
return device->isPaired()
? (device->isReachable() ? Connected : Trusted)
: (device->isReachable() ? Near : Nothing);
case TrustedRole:
return device->isTrusted();
return device->isPaired();
case ReachableRole:
return device->isReachable();
case HasPairingRequestsRole:
return device->hasPairingRequests();
return device->isPairRequestedByPeer();
case WaitsForPairingRole:
return device->waitsForPairing();
return device->isPairRequested();
}

return QVariant();
Expand Down Expand Up @@ -183,18 +177,12 @@ void DeviceListModel::connectDevice(Device *device)
connect(device, &Device::nameChanged, this, [=]{
deviceDataChanged(device, {Qt::DisplayRole, NameRole});
});
connect(device, &Device::trustedChanged, this, [=]{
deviceDataChanged(device, {TrustedRole});
connect(device, &Device::pairStateChanged, this, [=]{
deviceDataChanged(device, {TrustedRole, HasPairingRequestsRole, WaitsForPairingRole});
});
connect(device, &Device::reachableChanged, this, [=]{
deviceDataChanged(device, {ReachableRole});
});
connect(device, &Device::hasPairingRequestsChanged, this, [=]{
deviceDataChanged(device, {HasPairingRequestsRole});
});
connect(device, &Device::waitsForPairingChanged, this, [=]{
deviceDataChanged(device, {WaitsForPairingRole});
});
connect(device, &Device::destroyed, this, [=]{
//qCCritical(logger) << "device destroyed with id" << device->id();
deviceRemoved(device);
Expand Down
6 changes: 0 additions & 6 deletions conanfile.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
[tool_requires]
extra-cmake-modules/5.68.0@r1tschy/stable

[requires]
KF5CoreAddons/5.36.0@r1tschy/stable
KF5I18n/5.36.0@r1tschy/stable
KF5Config/5.36.0@r1tschy/stable
Qca-qt5/2.2.1@r1tschy/stable
libssh/0.9.5@r1tschy/stable

[options]
KF5CoreAddons/*:shared=False
KF5I18n/*:shared=False
KF5Config/*:shared=False

Qca-qt5/*:shared=False

[imports]
lib, *.so.* -> ./deps/lib

Expand Down
2 changes: 1 addition & 1 deletion kdeconnect-kde
Submodule kdeconnect-kde updated from 6e713b to 48bf64
6 changes: 2 additions & 4 deletions plugins/batteryreport/batteryreportplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,11 @@ BatteryReportPlugin::BatteryReportPlugin(QObject* parent, const QVariantList& ar
this, &BatteryReportPlugin::sendStatus);
}

bool BatteryReportPlugin::receivePacket(const NetworkPacket &np)
void BatteryReportPlugin::receivePacket(const NetworkPacket &np)
{
if (np.get<bool>(QStringLiteral("request"))) {
sendStatus();
}

return true;
}

void BatteryReportPlugin::connected()
Expand All @@ -211,4 +209,4 @@ void BatteryReportPlugin::sendStatus()
sendPacket(packet);
}

#include "batteryreportplugin.moc"
#include "batteryreportplugin.moc"
2 changes: 1 addition & 1 deletion plugins/batteryreport/batteryreportplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class BatteryReportPlugin : public KdeConnectPlugin

BatteryReportPlugin(QObject* parent, const QVariantList& args);

bool receivePacket(const NetworkPacket &np) override;
void receivePacket(const NetworkPacket &np) override;
void connected() override;

private:
Expand Down
4 changes: 1 addition & 3 deletions plugins/sf_clipboard/clipboardplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ClipboardPlugin::ClipboardPlugin(QObject* parent, const QVariantList& args)
, m_clipboard(QGuiApplication::clipboard())
{}

bool ClipboardPlugin::receivePacket(const NetworkPacket &np)
void ClipboardPlugin::receivePacket(const NetworkPacket &np)
{
QString content = np.get<QString>(QStringLiteral("content"));
if (np.type() == PACKET_TYPE_CLIPBOARD) {
Expand All @@ -49,8 +49,6 @@ bool ClipboardPlugin::receivePacket(const NetworkPacket &np)
m_clipboard->setText(content);
}
}

return true;
}

void ClipboardPlugin::pushClipboard()
Expand Down
2 changes: 1 addition & 1 deletion plugins/sf_clipboard/clipboardplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ClipboardPlugin : public KdeConnectPlugin
QString dbusPath() const override;

void connected() override {}
bool receivePacket(const NetworkPacket &np) override;
void receivePacket(const NetworkPacket &np) override;
Q_SCRIPTABLE void pushClipboard();

private:
Expand Down
6 changes: 2 additions & 4 deletions plugins/sf_mprisremote/mprisremoteplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,11 @@ MprisRemotePlugin::MprisRemotePlugin(QObject* parent, const QVariantList& args)
this, &MprisRemotePlugin::askForAlbumArt);
}

bool MprisRemotePlugin::receivePacket(const NetworkPacket& np)
void MprisRemotePlugin::receivePacket(const NetworkPacket& np)
{
if (np.get<bool>("transferringAlbumArt", false)) {
m_cache->endFetching(np.get<QString>("albumArtUrl"), np.payload(), np.payloadSize());
return true;
return;
}

m_supportAlbumArtPayload = np.get<bool>(
Expand Down Expand Up @@ -238,8 +238,6 @@ bool MprisRemotePlugin::receivePacket(const NetworkPacket& np)
emit playerRemoved(removedPlayer);
}
}

return true;
}

void MprisRemotePlugin::askForAlbumArt(
Expand Down
2 changes: 1 addition & 1 deletion plugins/sf_mprisremote/mprisremoteplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class MprisRemotePlugin : public KdeConnectPlugin
explicit MprisRemotePlugin(QObject* parent, const QVariantList& args);

void connected() override { }
bool receivePacket(const NetworkPacket& np) override;
void receivePacket(const NetworkPacket& np) override;

Q_SCRIPTABLE void sendCommand(
const QString& player, const QString& method, const QString& value);
Expand Down
3 changes: 1 addition & 2 deletions plugins/sf_sendnotifications/sendnotificationsplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ SendNotificationsPlugin::SendNotificationsPlugin(QObject* parent, const QVariant
, m_listener(new NotificationsListener(this))
{ }

bool SendNotificationsPlugin::receivePacket(const NetworkPacket&)
void SendNotificationsPlugin::receivePacket(const NetworkPacket&)
{
// impl. request for existing notifications
return false;
}

#include "sendnotificationsplugin.moc"
Expand Down
2 changes: 1 addition & 1 deletion plugins/sf_sendnotifications/sendnotificationsplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SendNotificationsPlugin : public KdeConnectPlugin
SendNotificationsPlugin(QObject* parent, const QVariantList& args);

void connected() override { }
bool receivePacket(const NetworkPacket &np) override;
void receivePacket(const NetworkPacket &np) override;

private:
NotificationsListener* m_listener;
Expand Down
6 changes: 2 additions & 4 deletions plugins/sf_share/shareplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ QString SharePlugin::incomingPath() const
}
}

bool SharePlugin::receivePacket(const NetworkPacket& np)
void SharePlugin::receivePacket(const NetworkPacket& np)
{
if (np.hasPayload()) {
const QString filename = escapeForFilePath(np.get<QString>(
Expand Down Expand Up @@ -112,7 +112,7 @@ bool SharePlugin::receivePacket(const NetworkPacket& np)
qCWarning(logger)
<< "Share failed: failed to create temporary text file"
<< tmpFile.fileName();
return true;
return;
}

tmpFile.write(text.toUtf8());
Expand All @@ -129,8 +129,6 @@ bool SharePlugin::receivePacket(const NetworkPacket& np)
} else {
qCWarning(logger) << "Empty share received";
}

return true;
}

void SharePlugin::shareUrl(const QUrl& url, bool open)
Expand Down
2 changes: 1 addition & 1 deletion plugins/sf_share/shareplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SharePlugin : public KdeConnectPlugin
QString incomingPath() const;

void connected() override { }
bool receivePacket(const NetworkPacket &np) override;
void receivePacket(const NetworkPacket &np) override;

Q_SCRIPTABLE void shareUrl(const QString& url) { shareUrl(QUrl(url), false); }
Q_SCRIPTABLE void shareUrls(const QStringList& urls);
Expand Down
5 changes: 1 addition & 4 deletions plugins/sftpserver/sftpserverplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static const QString PACKET_TYPE_SFTP = QStringLiteral("kdeconnect.sftp");
static const QString PACKET_TYPE_SFTP_REQUEST = QStringLiteral("kdeconnect.sftp.request");


bool SftpServerPlugin::receivePacket(const NetworkPacket& np)
void SftpServerPlugin::receivePacket(const NetworkPacket& np)
{
if (np.type() == PACKET_TYPE_SFTP_REQUEST) {
if (np.get<bool>("startBrowsing")) {
Expand All @@ -40,10 +40,7 @@ bool SftpServerPlugin::receivePacket(const NetworkPacket& np)
NetworkPacket resultNp(PACKET_TYPE_SFTP);

sendPacket(resultNp);
return true;
}

return false;
}

#include "sftpserverplugin.moc"
2 changes: 1 addition & 1 deletion plugins/sftpserver/sftpserverplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ class SftpServerPlugin : public KdeConnectPlugin
using KdeConnectPlugin::KdeConnectPlugin;

void connected() override {}
bool receivePacket(const NetworkPacket &np) override;
void receivePacket(const NetworkPacket &np) override;
};
Loading

0 comments on commit 720f59e

Please sign in to comment.