kdeconnect-kde/plugins/share/shareplugin.h

53 lines
1.6 KiB
C
Raw Normal View History

2013-08-13 23:09:46 +01:00
/**
* SPDX-FileCopyrightText: 2013 Albert Vaca <albertvaka@gmail.com>
2013-08-13 23:09:46 +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
*/
#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/kdeconnectplugin.h>
2019-06-02 15:02:21 +01:00
#include <core/compositefiletransferjob.h>
2013-08-13 23:09:46 +01:00
#define PACKET_TYPE_SHARE_REQUEST QStringLiteral("kdeconnect.share.request")
#define PACKET_TYPE_SHARE_REQUEST_UPDATE QStringLiteral("kdeconnect.share.request.update")
class SharePlugin
2013-08-13 23:09:46 +01:00
: public KdeConnectPlugin
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.share")
2013-08-13 23:09:46 +01:00
public:
explicit SharePlugin(QObject* parent, const QVariantList& args);
2013-08-13 23:09:46 +01:00
///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 {}
QString dbusPath() const override;
private Q_SLOTS:
void openDestinationFolder();
Q_SIGNALS:
2019-03-06 08:22:06 +00:00
Q_SCRIPTABLE void shareReceived(const QString& url);
private:
void finished(KJob* job, const qint64 dateModified, const bool open);
void shareUrl(const QUrl& url, bool open);
QUrl destinationDir() const;
QUrl getFileDestination(const QString filename) const;
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