[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498
Maximiliano Curia
maxy at moszumanska.debian.org
Fri Oct 14 14:27:03 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=44f5c70
The following commit has been merged in the master branch:
commit 44f5c7093e878478994b4120dbcbadb0b8b874f8
Author: Albert Vaca <albertvaka at gmail.com>
Date: Fri Sep 27 03:01:13 2013 +0200
Finished implementing file transfer
Implemented support for text and url share
---
kded/plugins/filetransfer/README | 4 +--
kded/plugins/filetransfer/filetransferplugin.cpp | 32 ++++++++++++++++++++----
2 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/kded/plugins/filetransfer/README b/kded/plugins/filetransfer/README
index 817efc0..369170f 100644
--- a/kded/plugins/filetransfer/README
+++ b/kded/plugins/filetransfer/README
@@ -3,9 +3,9 @@ It receives a packages with type kdeconnect.filetransfer. If they have a payload
attached, it will download it as a file with the filename set in the field
"filename" (string). If that field is not set it should generate a filename.
-<TODO>
If the content transferred is text, it can be sent in a field "text" (string)
instead of an attached payload. In that case, this plugin opens a text editor
with the content instead of saving it as a file.
-</TODO>
+If the content transferred is a url, it can be sent in a field "url" (string).
+In that case, this plugin opens that url in the default browser.
diff --git a/kded/plugins/filetransfer/filetransferplugin.cpp b/kded/plugins/filetransfer/filetransferplugin.cpp
index 088d7c5..bbf5caf 100644
--- a/kded/plugins/filetransfer/filetransferplugin.cpp
+++ b/kded/plugins/filetransfer/filetransferplugin.cpp
@@ -26,6 +26,7 @@
#include <QDebug>
#include <QFile>
+#include <qprocess.h>
#include <QDesktopServices>
#include "../../filetransferjob.h"
@@ -45,8 +46,8 @@ FileTransferPlugin::FileTransferPlugin(QObject* parent, const QVariantList& args
bool FileTransferPlugin::receivePackage(const NetworkPackage& np)
{
-
- //TODO: Move this code to a test and do a diff between files
+/*
+ //TODO: Move this code to a test and add a diff between files
if (np.type() == PACKAGE_TYPE_PING) {
qDebug() << "sending file" << (QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + "/.bashrc");
@@ -63,16 +64,37 @@ bool FileTransferPlugin::receivePackage(const NetworkPackage& np)
return true;
}
-
+*/
if (np.type() != PACKAGE_TYPE_FILETRANSFER) return false;
qDebug() << "File transfer";
if (np.hasPayload()) {
qDebug() << "receiving file";
- QString filename = np.get<QString>("filename", mDestinationDir + QString::number(QDateTime::currentMSecsSinceEpoch()));
- FileTransferJob* job = np.createPayloadTransferJob(filename);
+ QString filename = np.get<QString>("filename", QString::number(QDateTime::currentMSecsSinceEpoch()));
+ FileTransferJob* job = np.createPayloadTransferJob(mDestinationDir + filename);
connect(job, SIGNAL(result(KJob*)), this, SLOT(finished(KJob*)));
job->start();
+ } else if (np.has("text")) {
+ QString text = np.get<QString>("text");
+ if (!KStandardDirs::findExe("kate").isEmpty()) {
+ QProcess* proc = new QProcess();
+ connect(proc, SIGNAL(finished(int)), proc, SLOT(deleteLater()));
+ proc->start("kate", QStringList("--stdin"));
+ proc->write(text.toUtf8());
+ proc->closeWriteChannel();
+ } else {
+ QTemporaryFile tmpFile;
+ tmpFile.setAutoRemove(false);
+ tmpFile.open();
+ tmpFile.write(text.toUtf8());
+ tmpFile.close();
+ QDesktopServices::openUrl(QUrl::fromLocalFile(tmpFile.fileName()));
+ }
+ } else if (np.has("url")) {
+ QUrl url(np.get<QString>("url"));
+ QDesktopServices::openUrl(url);
+ } else {
+ qDebug() << "Error: Nothing attached!";
}
return true;
--
kdeconnect packaging
More information about the pkg-kde-commits
mailing list