[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498
Maximiliano Curia
maxy at moszumanska.debian.org
Fri Oct 14 14:27:40 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=a2e6632
The following commit has been merged in the master branch:
commit a2e6632759f4e07abea37c244fd6eafa9cbfe9ce
Author: Aleix Pol <aleixpol at kde.org>
Date: Sat Jun 14 18:45:53 2014 +0200
Introduce a fileitemactionplugin
This way we can send files to all devices.
---
CMakeLists.txt | 1 +
fileitemactionplugin/CMakeLists.txt | 6 ++
fileitemactionplugin/kdeconnectsendfile.desktop | 9 +++
fileitemactionplugin/sendfileitemaction.cpp | 79 +++++++++++++++++++++++++
fileitemactionplugin/sendfileitemaction.h | 43 ++++++++++++++
5 files changed, 138 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c2a5dc1..5b916d9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,5 +27,6 @@ add_subdirectory(kded)
add_subdirectory(plugins)
add_subdirectory(plasmoid)
add_subdirectory(cli)
+add_subdirectory(fileitemactionplugin)
add_subdirectory(tests)
diff --git a/fileitemactionplugin/CMakeLists.txt b/fileitemactionplugin/CMakeLists.txt
new file mode 100644
index 0000000..3043f69
--- /dev/null
+++ b/fileitemactionplugin/CMakeLists.txt
@@ -0,0 +1,6 @@
+include_directories(${CMAKE_SOURCE_DIR})
+
+kde4_add_plugin(kdeconnectfiletiemaction sendfileitemaction.cpp)
+target_link_libraries(kdeconnectfiletiemaction ${KDE4_KIO_LIBS} kdeconnectinterfaces)
+install(TARGETS kdeconnectfiletiemaction DESTINATION ${PLUGIN_INSTALL_DIR})
+install(FILES kdeconnectsendfile.desktop DESTINATION ${SERVICES_INSTALL_DIR})
diff --git a/fileitemactionplugin/kdeconnectsendfile.desktop b/fileitemactionplugin/kdeconnectsendfile.desktop
new file mode 100644
index 0000000..aa65875
--- /dev/null
+++ b/fileitemactionplugin/kdeconnectsendfile.desktop
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Type=Service
+Name=Send file via KDE Connect service
+X-KDE-Library=kdeconnectfiletiemaction
+X-KDE-Submenu=Connect
+
+Icon=preferences-system-network
+ServiceTypes=KFileItemAction/Plugin
+MimeType=application/octet-stream
diff --git a/fileitemactionplugin/sendfileitemaction.cpp b/fileitemactionplugin/sendfileitemaction.cpp
new file mode 100644
index 0000000..e2b71e6
--- /dev/null
+++ b/fileitemactionplugin/sendfileitemaction.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2011 Alejandro Fiestas Olivares <afiestas at kde.org>
+ * Copyright (C) 2014 Aleix Pol Gonzalez <aleixpol at kde.org>
+ *
+ * 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) any later version.
+ *
+ * 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 Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "sendfileitemaction.h"
+#include <interfaces/devicesmodel.h>
+#include <interfaces/dbusinterfaces.h>
+
+#include <QList>
+#include <QMenu>
+#include <QAction>
+#include <QWidget>
+#include <QMessageBox>
+#include <QVariantList>
+
+#include <KIcon>
+#include <KPluginFactory>
+#include <KPluginLoader>
+
+#include <KDebug>
+#include <KProcess>
+#include <KLocalizedString>
+
+K_PLUGIN_FACTORY(SendFileItemActionFactory, registerPlugin<SendFileItemAction>();)
+K_EXPORT_PLUGIN(SendFileItemActionFactory("SendFileItemAction", "kdeconnectfiletiemaction"))
+
+SendFileItemAction::SendFileItemAction(QObject* parent, const QVariantList& ): KFileItemActionPlugin(parent)
+{
+}
+
+QList<QAction*> SendFileItemAction::actions(const KFileItemListProperties& fileItemInfos, QWidget* parentWidget) const
+{
+ DevicesModel m;
+
+ QAction *menuAction = new QAction(QIcon::fromTheme("preferences-system-network"), i18n("Send via KDE Connect"), parentWidget);
+ QMenu *menu = new QMenu();
+
+ for(int i = 0; i<m.rowCount(); ++i) {
+ QModelIndex idx = m.index(i);
+ DeviceDbusInterface* dev = m.getDevice(idx);
+ if(dev->isReachable() && dev->isPaired()) {
+ QAction* action = menu->addAction(dev->name(), this, SLOT(sendFile()));
+ action->setProperty("id", idx.data(DevicesModel::IdModelRole));
+ action->setProperty("urls", QVariant::fromValue(fileItemInfos.urlList()));
+ action->setProperty("parentWidget", QVariant::fromValue(parentWidget));
+ }
+ }
+
+ menuAction->setMenu(menu);
+
+ return QList<QAction*>() << menuAction;
+}
+
+void SendFileItemAction::sendFile()
+{
+ QList<QUrl> urls = sender()->property("urls").value<KUrl::List>();
+ foreach(const QUrl& url, urls) {
+ QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+sender()->property("id").toString()+"/share", "org.kde.kdeconnect.device.share", "shareUrl");
+ msg.setArguments(QVariantList() << url.toString());
+
+ QDBusConnection::sessionBus().call(msg);
+ }
+}
diff --git a/fileitemactionplugin/sendfileitemaction.h b/fileitemactionplugin/sendfileitemaction.h
new file mode 100644
index 0000000..d5dd74b
--- /dev/null
+++ b/fileitemactionplugin/sendfileitemaction.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011 Alejandro Fiestas Olivares <afiestas at kde.org>
+ * Copyright (C) 2014 Aleix Pol Gonzalez <aleixpol at kde.org>
+ *
+ * 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) any later version.
+ *
+ * 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 Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SENDFILEITEMACTION_H
+#define SENDFILEITEMACTION_H
+
+#include <kfileitemactionplugin.h>
+#include <KFileItemListProperties>
+
+class QAction;
+class KFileItemListProperties;
+class QWidget;
+
+class SendFileItemAction : public KFileItemActionPlugin
+{
+Q_OBJECT
+public:
+ SendFileItemAction(QObject* parent, const QVariantList &args);
+ virtual QList< QAction* > actions(const KFileItemListProperties& fileItemInfos, QWidget* parentWidget) const;
+
+private Q_SLOTS:
+ void sendFile();
+
+};
+
+#endif // SENDFILEITEMACTION_H
--
kdeconnect packaging
More information about the pkg-kde-commits
mailing list