2013-08-13 23:09:46 +01:00
|
|
|
/**
|
|
|
|
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License or (at your option) version 3 or any later version
|
|
|
|
* accepted by the membership of KDE e.V. (or its successor approved
|
|
|
|
* by the membership of KDE e.V.), which shall act as a proxy
|
|
|
|
* defined in Section 14 of version 3 of the license.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2019-03-23 16:29:26 +00:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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>
|
|
|
|
|
2014-06-14 15:34:00 +01:00
|
|
|
#include <core/kdeconnectplugin.h>
|
2019-06-02 15:02:21 +01:00
|
|
|
#include <core/compositefiletransferjob.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
|
|
|
|
2013-11-23 00:39:10 +00:00
|
|
|
class SharePlugin
|
2013-08-13 23:09:46 +01:00
|
|
|
: public KdeConnectPlugin
|
|
|
|
{
|
|
|
|
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:
|
2017-09-03 20:39:44 +01:00
|
|
|
explicit SharePlugin(QObject* parent, const QVariantList& args);
|
2013-08-13 23:09:46 +01:00
|
|
|
|
2014-03-03 03:53:11 +00:00
|
|
|
///Helper method, QDBus won't recognize QUrl
|
2019-06-17 22:35:53 +01:00
|
|
|
Q_SCRIPTABLE void shareUrl(const QString& url) { shareUrl(QUrl(url), false); }
|
2018-11-28 18:56:22 +00:00
|
|
|
Q_SCRIPTABLE void shareUrls(const QStringList& urls);
|
2018-11-03 21:16:07 +00:00
|
|
|
Q_SCRIPTABLE void shareText(const QString& text);
|
2019-06-17 22:35:53 +01:00
|
|
|
Q_SCRIPTABLE void openFile(const QString& file) { shareUrl(QUrl(file), true); }
|
2016-12-30 15:38:12 +00:00
|
|
|
|
2018-03-04 19:48:51 +00:00
|
|
|
bool receivePacket(const NetworkPacket& np) override;
|
2016-12-30 15:38:12 +00:00
|
|
|
void connected() override {}
|
|
|
|
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:
|
2019-03-06 08:22:06 +00: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:
|
2019-05-11 20:52:00 +01:00
|
|
|
void finished(KJob* job, const qint64 dateModified);
|
2019-06-17 22:35:53 +01:00
|
|
|
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;
|
2019-05-11 20:52:00 +01:00
|
|
|
void setDateModified(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
|