2013-08-13 23:09:46 +01:00
|
|
|
/**
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-FileCopyrightText: 2013 Albert Vaca <albertvaka@gmail.com>
|
2013-08-13 23:09:46 +01:00
|
|
|
*
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
2013-08-13 23:09:46 +01:00
|
|
|
*/
|
|
|
|
|
2013-11-23 00:39:10 +00:00
|
|
|
#ifndef SHAREPLUGIN_H
|
|
|
|
#define SHAREPLUGIN_H
|
2013-08-13 23:09:46 +01:00
|
|
|
|
2019-06-02 15:02:21 +01:00
|
|
|
#include <QPointer>
|
|
|
|
|
|
|
|
#include <core/compositefiletransferjob.h>
|
2022-09-10 22:23:52 +01:00
|
|
|
#include <core/kdeconnectplugin.h>
|
2013-08-13 23:09:46 +01:00
|
|
|
|
2018-03-04 19:48:51 +00:00
|
|
|
#define PACKET_TYPE_SHARE_REQUEST QStringLiteral("kdeconnect.share.request")
|
2019-01-26 16:43:09 +00:00
|
|
|
#define PACKET_TYPE_SHARE_REQUEST_UPDATE QStringLiteral("kdeconnect.share.request.update")
|
2013-10-11 14:19:23 +01:00
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
class SharePlugin : public KdeConnectPlugin
|
2013-08-13 23:09:46 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2014-03-03 03:53:11 +00:00
|
|
|
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.share")
|
2013-08-13 23:09:46 +01:00
|
|
|
|
|
|
|
public:
|
2022-09-10 22:23:52 +01:00
|
|
|
explicit SharePlugin(QObject *parent, const QVariantList &args);
|
|
|
|
|
|
|
|
/// Helper method, QDBus won't recognize QUrl
|
|
|
|
Q_SCRIPTABLE void shareUrl(const QString &url)
|
|
|
|
{
|
|
|
|
shareUrl(QUrl(url), false);
|
|
|
|
}
|
|
|
|
Q_SCRIPTABLE void shareUrls(const QStringList &urls);
|
|
|
|
Q_SCRIPTABLE void shareText(const QString &text);
|
|
|
|
Q_SCRIPTABLE void openFile(const QString &file)
|
|
|
|
{
|
|
|
|
shareUrl(QUrl(file), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool receivePacket(const NetworkPacket &np) override;
|
|
|
|
void connected() override
|
|
|
|
{
|
|
|
|
}
|
2016-12-30 15:38:12 +00:00
|
|
|
QString dbusPath() const override;
|
2013-09-10 18:01:46 +01:00
|
|
|
|
2013-10-01 01:44:49 +01:00
|
|
|
private Q_SLOTS:
|
|
|
|
void openDestinationFolder();
|
|
|
|
|
2015-09-07 13:54:33 +01:00
|
|
|
Q_SIGNALS:
|
2022-09-10 22:23:52 +01:00
|
|
|
Q_SCRIPTABLE void shareReceived(const QString &url);
|
2015-09-07 13:54:33 +01:00
|
|
|
|
2013-09-10 18:01:46 +01:00
|
|
|
private:
|
2022-09-10 22:23:52 +01:00
|
|
|
void finished(KJob *job, const qint64 dateCreated, const qint64 dateModified, const bool open);
|
|
|
|
void shareUrl(const QUrl &url, bool open);
|
2014-09-21 21:24:37 +01:00
|
|
|
QUrl destinationDir() const;
|
2018-11-26 17:02:42 +00:00
|
|
|
QUrl getFileDestination(const QString filename) const;
|
2022-09-10 22:23:52 +01:00
|
|
|
void setDateModified(const QUrl &destination, const qint64 timestamp);
|
|
|
|
void setDateCreated(const QUrl &destination, const qint64 timestamp);
|
2019-06-02 15:02:21 +01:00
|
|
|
|
|
|
|
QPointer<CompositeFileTransferJob> m_compositeJob;
|
2013-08-13 23:09:46 +01:00
|
|
|
};
|
|
|
|
#endif
|