Improve SharePlugin share notification method
Make the share received notification explicitly internal. Fix runtime warning about how QUrl cannot be exported. Notify about all shares, not exclusively transferred files.
This commit is contained in:
parent
70f55d0ebc
commit
42110549f4
3 changed files with 10 additions and 6 deletions
|
@ -114,11 +114,15 @@ bool SharePlugin::receivePackage(const NetworkPackage& np)
|
||||||
tmpFile.open();
|
tmpFile.open();
|
||||||
tmpFile.write(text.toUtf8());
|
tmpFile.write(text.toUtf8());
|
||||||
tmpFile.close();
|
tmpFile.close();
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(tmpFile.fileName()));
|
|
||||||
|
const QUrl url = QUrl::fromLocalFile(tmpFile.fileName());
|
||||||
|
Q_EMIT shareReceived(url);
|
||||||
|
QDesktopServices::openUrl(url);
|
||||||
}
|
}
|
||||||
} else if (np.has("url")) {
|
} else if (np.has("url")) {
|
||||||
QUrl url = QUrl::fromEncoded(np.get<QByteArray>("url"));
|
QUrl url = QUrl::fromEncoded(np.get<QByteArray>("url"));
|
||||||
QDesktopServices::openUrl(url);
|
QDesktopServices::openUrl(url);
|
||||||
|
Q_EMIT shareReceived(url);
|
||||||
} else {
|
} else {
|
||||||
qCDebug(KDECONNECT_PLUGIN_SHARE) << "Error: Nothing attached!";
|
qCDebug(KDECONNECT_PLUGIN_SHARE) << "Error: Nothing attached!";
|
||||||
}
|
}
|
||||||
|
@ -131,7 +135,7 @@ void SharePlugin::finished(KJob* job)
|
||||||
{
|
{
|
||||||
FileTransferJob* ftjob = qobject_cast<FileTransferJob*>(job);
|
FileTransferJob* ftjob = qobject_cast<FileTransferJob*>(job);
|
||||||
if (ftjob)
|
if (ftjob)
|
||||||
fileReceived(ftjob->destination());
|
Q_EMIT shareReceived(ftjob->destination());
|
||||||
|
|
||||||
qCDebug(KDECONNECT_PLUGIN_SHARE) << "File transfer finished. Success:" << (!job->error()) << (ftjob ? ftjob->destination() : QUrl());
|
qCDebug(KDECONNECT_PLUGIN_SHARE) << "File transfer finished. Success:" << (!job->error()) << (ftjob ? ftjob->destination() : QUrl());
|
||||||
}
|
}
|
||||||
|
@ -156,7 +160,7 @@ void SharePlugin::shareUrl(const QUrl& url)
|
||||||
|
|
||||||
void SharePlugin::connected()
|
void SharePlugin::connected()
|
||||||
{
|
{
|
||||||
QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportAllContents);
|
QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportScriptableContents);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SharePlugin::dbusPath() const
|
QString SharePlugin::dbusPath() const
|
||||||
|
|
|
@ -48,7 +48,7 @@ private Q_SLOTS:
|
||||||
void openDestinationFolder();
|
void openDestinationFolder();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void fileReceived(const QUrl& url);
|
void shareReceived(const QUrl& url);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void shareUrl(const QUrl& url);
|
void shareUrl(const QUrl& url);
|
||||||
|
|
|
@ -97,11 +97,11 @@ class TestSendFile : public QObject
|
||||||
QVERIFY(plugin);
|
QVERIFY(plugin);
|
||||||
plugin->metaObject()->invokeMethod(plugin, "shareUrl", Q_ARG(QString, QUrl::fromLocalFile(temp.fileName()).toString()));
|
plugin->metaObject()->invokeMethod(plugin, "shareUrl", Q_ARG(QString, QUrl::fromLocalFile(temp.fileName()).toString()));
|
||||||
|
|
||||||
QSignalSpy spy(plugin, SIGNAL(fileReceived(QUrl)));
|
QSignalSpy spy(plugin, SIGNAL(shareReceived(QUrl)));
|
||||||
QVERIFY(spy.wait(2000));
|
QVERIFY(spy.wait(2000));
|
||||||
|
|
||||||
QVariantList args = spy.takeFirst();
|
QVariantList args = spy.takeFirst();
|
||||||
QUrl sentFile = args.first().toUrl();
|
QUrl sentFile(args.first().toUrl());
|
||||||
|
|
||||||
QFile file(sentFile.toLocalFile());
|
QFile file(sentFile.toLocalFile());
|
||||||
QCOMPARE(file.size(), content.size());
|
QCOMPARE(file.size(), content.size());
|
||||||
|
|
Loading…
Reference in a new issue