File indexing completed on 2024-10-06 04:31:38

0001 /**
0002  * SPDX-FileCopyrightText: 2019 Piyush Aggarwal <piyushaggarwal002@gmail.com>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #pragma once
0008 
0009 #include <core/device.h>
0010 #include <core/kdeconnectplugin.h>
0011 
0012 #define PACKET_TYPE_SFTP_REQUEST QStringLiteral("kdeconnect.sftp.request")
0013 
0014 static const QSet<QString> expectedFields = QSet<QString>()
0015     << QStringLiteral("ip") << QStringLiteral("port") << QStringLiteral("user") << QStringLiteral("password") << QStringLiteral("path");
0016 ;
0017 class SftpPlugin : public KdeConnectPlugin
0018 {
0019     Q_OBJECT
0020     Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.sftp")
0021 
0022 public:
0023     explicit SftpPlugin(QObject *parent, const QVariantList &args);
0024 
0025     void receivePacket(const NetworkPacket &np) override;
0026     QString dbusPath() const override
0027     {
0028         return QLatin1String("/modules/kdeconnect/devices/%1/sftp").arg(deviceId);
0029     }
0030 
0031 public Q_SLOTS:
0032     Q_SCRIPTABLE bool startBrowsing();
0033 
0034 private:
0035     QString deviceId; // Storing it to avoid accessing device() from the destructor which could cause a crash
0036 };