diff --git a/kio/kiokdeconnect.cpp b/kio/kiokdeconnect.cpp index 09acd428b..b7420934c 100644 --- a/kio/kiokdeconnect.cpp +++ b/kio/kiokdeconnect.cpp @@ -136,44 +136,38 @@ void KioKdeconnect::listDevice() QDBusReply mountreply = interface.mountAndWait(); - if (handleDBusError(mountreply, this)) - { + if (handleDBusError(mountreply, this)) { return; } - if (!mountreply.value()) - { + if (!mountreply.value()) { error(KIO::ERR_COULD_NOT_MOUNT, i18n("Could not mount device filesystem")); return; } - QDBusReply urlreply = interface.mountPoint(); + QDBusReply< QVariantMap > urlreply = interface.getDirectories(); - if (handleDBusError(urlreply, this)) - { + if (handleDBusError(urlreply, this)) { return; } - QString url = urlreply.value(); + QVariantMap urls = urlreply.value(); - KIO::UDSEntry entry; - entry.insert(KIO::UDSEntry::UDS_NAME, "files"); - entry.insert(KIO::UDSEntry::UDS_DISPLAY_NAME, i18n("Camera pictures")); - entry.insert(KIO::UDSEntry::UDS_ICON_NAME, "folder"); - entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR); - entry.insert(KIO::UDSEntry::UDS_ACCESS, S_IRUSR | S_IRGRP | S_IROTH); - entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, ""); - entry.insert(KIO::UDSEntry::UDS_URL, url + "/DCIM/Camera"); - listEntry(entry, false); + for (QVariantMap::iterator it = urls.begin(); it != urls.end(); it++) { - entry.insert(KIO::UDSEntry::UDS_NAME, "files"); - entry.insert(KIO::UDSEntry::UDS_DISPLAY_NAME, i18n("All files")); - entry.insert(KIO::UDSEntry::UDS_ICON_NAME, "folder"); - entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR); - entry.insert(KIO::UDSEntry::UDS_ACCESS, S_IRUSR | S_IRGRP | S_IROTH); - entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, ""); - entry.insert(KIO::UDSEntry::UDS_URL, url); - listEntry(entry, false); + QString path = it.key(); + QString name = it.value().toString(); + + KIO::UDSEntry entry; + entry.insert(KIO::UDSEntry::UDS_NAME, "files"); + entry.insert(KIO::UDSEntry::UDS_DISPLAY_NAME, name); + entry.insert(KIO::UDSEntry::UDS_ICON_NAME, "folder"); + entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR); + entry.insert(KIO::UDSEntry::UDS_ACCESS, S_IRUSR | S_IRGRP | S_IROTH); + entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, ""); + entry.insert(KIO::UDSEntry::UDS_URL, path); + listEntry(entry, false); + } listEntry(KIO::UDSEntry(), true); infoMessage(""); diff --git a/plugins/sftp/mounter.cpp b/plugins/sftp/mounter.cpp index 752c3f441..c414f77b1 100644 --- a/plugins/sftp/mounter.cpp +++ b/plugins/sftp/mounter.cpp @@ -120,11 +120,16 @@ void Mounter::onPakcageReceived(const NetworkPackage& np) QDir().mkpath(mpoint); const QString program = "sshfs"; + + QString path; + if (np.has("multiPaths")) path = "/"; + else path = np.get("path"); + const QStringList arguments = QStringList() << QString("%1@%2:%3") .arg(np.get("user")) .arg(np.get("ip")) - .arg(np.get("path")) + .arg(path) << mpoint << "-p" << np.get("port") << "-d" diff --git a/plugins/sftp/sftp_config.cpp b/plugins/sftp/sftp_config.cpp index 119fe5b5d..c996dd3f8 100644 --- a/plugins/sftp/sftp_config.cpp +++ b/plugins/sftp/sftp_config.cpp @@ -70,7 +70,6 @@ void SftpConfig::defaults() Q_EMIT changed(true); } - void SftpConfig::load() { KCModule::load(); diff --git a/plugins/sftp/sftpplugin.cpp b/plugins/sftp/sftpplugin.cpp index a960f6bf1..53b818a99 100644 --- a/plugins/sftp/sftpplugin.cpp +++ b/plugins/sftp/sftpplugin.cpp @@ -53,7 +53,7 @@ struct SftpPlugin::Pimpl SftpPlugin::SftpPlugin(QObject *parent, const QVariantList &args) : KdeConnectPlugin(parent, args) - , m_d(new Pimpl) + , m_d(new Pimpl()) { addToDolphin(); kDebug(debugArea()) << "Created device:" << device()->name(); @@ -140,14 +140,26 @@ bool SftpPlugin::startBrowsing() bool SftpPlugin::receivePackage(const NetworkPackage& np) { - if (!(fields_c - np.body().keys().toSet()).isEmpty()) - { + if (!(fields_c - np.body().keys().toSet()).isEmpty()) { // package is invalid return false; } Q_EMIT packageReceived(np); + remoteDirectories.clear(); + if (np.has("multiPaths")) { + QStringList paths = np.get("multiPaths",QStringList()); + QStringList names = np.get("pathNames",QStringList()); + int size = qMin(names.size(), paths.size()); + for (int i = 0; i < size; i++) { + remoteDirectories.insert(mountPoint() + paths.at(i), names.at(i)); + } + } else { + remoteDirectories.insert(mountPoint(), i18n("All files")); + remoteDirectories.insert(mountPoint() + "/DCIM/Camera", i18n("Camera pictures")); + } + return true; } @@ -196,3 +208,9 @@ void SftpPlugin::knotify(int type, const QString& text, const QPixmap& icon) con , KNotification::CloseOnTimeout); } +QVariantMap SftpPlugin::getDirectories() +{ + return remoteDirectories; +} + + diff --git a/plugins/sftp/sftpplugin.h b/plugins/sftp/sftpplugin.h index 9517d8e71..8c77d621c 100644 --- a/plugins/sftp/sftpplugin.h +++ b/plugins/sftp/sftpplugin.h @@ -35,12 +35,10 @@ class SftpPlugin Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.sftp") public: - explicit SftpPlugin(QObject *parent, const QVariantList &args); virtual ~SftpPlugin(); Q_SIGNALS: - void packageReceived(const NetworkPackage& np); Q_SCRIPTABLE void mounted(); Q_SCRIPTABLE void unmounted(); @@ -53,11 +51,10 @@ public Q_SLOTS: Q_SCRIPTABLE void unmount(); Q_SCRIPTABLE bool mountAndWait(); Q_SCRIPTABLE bool isMounted() const; - + Q_SCRIPTABLE bool startBrowsing(); Q_SCRIPTABLE QString mountPoint(); - - + Q_SCRIPTABLE QVariantMap getDirectories(); //Actually a QMap, but QDBus preffers this private Q_SLOTS: void onMounted(); @@ -73,6 +70,8 @@ private: private: struct Pimpl; QScopedPointer m_d; + + QVariantMap remoteDirectories; //Actually a QMap, but QDBus preffers this };