Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
kdeconnect-kde
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Weixuan Xiao
kdeconnect-kde
Commits
44f5c709
Commit
44f5c709
authored
Sep 27, 2013
by
Albert Vaca Cintora
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished implementing file transfer
Implemented support for text and url share
parent
f53f70d7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
7 deletions
+29
-7
kded/plugins/filetransfer/README
kded/plugins/filetransfer/README
+2
-2
kded/plugins/filetransfer/filetransferplugin.cpp
kded/plugins/filetransfer/filetransferplugin.cpp
+27
-5
No files found.
kded/plugins/filetransfer/README
View file @
44f5c709
...
...
@@ -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.
kded/plugins/filetransfer/filetransferplugin.cpp
View file @
44f5c709
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment