diff --git a/fileitemactionplugin/sendfileitemaction.cpp b/fileitemactionplugin/sendfileitemaction.cpp index c959b2f2d..157cbc571 100644 --- a/fileitemactionplugin/sendfileitemaction.cpp +++ b/fileitemactionplugin/sendfileitemaction.cpp @@ -19,23 +19,21 @@ */ #include "sendfileitemaction.h" -#include -#include #include #include #include #include -#include #include - +#include #include + #include #include - -#include #include -#include + +#include +#include K_PLUGIN_FACTORY(SendFileItemActionFactory, registerPlugin();) @@ -47,21 +45,30 @@ SendFileItemAction::SendFileItemAction(QObject* parent, const QVariantList& ): K QList SendFileItemAction::actions(const KFileItemListProperties& fileItemInfos, QWidget* parentWidget) { - DevicesModel m; - QList actions; - for(int i = 0; iisReachable() && dev->isPaired()) { - QAction* action = new QAction(QIcon::fromTheme(dev->iconName()), dev->name(), parentWidget); - action->setProperty("id", idx.data(DevicesModel::IdModelRole)); - action->setProperty("urls", QVariant::fromValue(fileItemInfos.urlList())); - action->setProperty("parentWidget", QVariant::fromValue(parentWidget)); - connect(action, SIGNAL(triggered(bool)), this, SLOT(sendFile())); - actions += action; + DaemonDbusInterface iface; + if (!iface.isValid()) { + return actions; + } + + QDBusPendingReply reply = iface.devices(true, true); + reply.waitForFinished(); + const QStringList devices = reply.value(); + foreach (const QString& id, devices) { + DeviceDbusInterface deviceIface(id); + if (!deviceIface.isValid()) { + continue; } + if (!deviceIface.hasPlugin("kdeconnect_share")) { + continue; + } + QAction* action = new QAction(QIcon::fromTheme(deviceIface.iconName()), deviceIface.name(), parentWidget); + action->setProperty("id", id); + action->setProperty("urls", QVariant::fromValue(fileItemInfos.urlList())); + action->setProperty("parentWidget", QVariant::fromValue(parentWidget)); + connect(action, SIGNAL(triggered(bool)), this, SLOT(sendFile())); + actions += action; } if (actions.count() > 1) { @@ -81,10 +88,10 @@ QList SendFileItemAction::actions(const KFileItemListProperties& fileI void SendFileItemAction::sendFile() { QList urls = sender()->property("urls").value>(); + QString id = sender()->property("id").toString(); 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"); + QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+id+"/share", "org.kde.kdeconnect.device.share", "shareUrl"); msg.setArguments(QVariantList() << url.toString()); - QDBusConnection::sessionBus().call(msg); } }